diff options
-rw-r--r-- | include/libbb.h | 2 | ||||
-rw-r--r-- | networking/arping.c | 12 | ||||
-rw-r--r-- | networking/hostname.c | 7 |
3 files changed, 9 insertions, 12 deletions
diff --git a/include/libbb.h b/include/libbb.h index 8cd4bc377..fda0dbe40 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -338,8 +338,6 @@ char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa, socklen_t salen) | |||
338 | // "old" (ipv4 only) API | 338 | // "old" (ipv4 only) API |
339 | // users: traceroute.c hostname.c ifconfig.c ping.c | 339 | // users: traceroute.c hostname.c ifconfig.c ping.c |
340 | struct hostent *xgethostbyname(const char *name); | 340 | struct hostent *xgethostbyname(const char *name); |
341 | //TODO: eliminate gethostbyname2 in arping (the only remaining place), | ||
342 | //use host_and_af2sockaddr instead. | ||
343 | 341 | ||
344 | 342 | ||
345 | extern char *xstrdup(const char *s); | 343 | extern char *xstrdup(const char *s); |
diff --git a/networking/arping.c b/networking/arping.c index 55b27872b..725b0e4cb 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -305,13 +305,11 @@ int arping_main(int argc, char **argv) | |||
305 | } | 305 | } |
306 | 306 | ||
307 | if (!inet_aton(target, &dst)) { | 307 | if (!inet_aton(target, &dst)) { |
308 | struct hostent *hp; | 308 | len_and_sockaddr *lsa; |
309 | 309 | lsa = host_and_af2sockaddr(target, 0, AF_INET); | |
310 | hp = gethostbyname2(target, AF_INET); | 310 | memcpy(&dst, &lsa->sin.sin_addr.s_addr, 4); |
311 | if (!hp) { | 311 | if (ENABLE_FEATURE_CLEAN_UP) |
312 | bb_error_msg_and_die("invalid or unknown target %s", target); | 312 | free(lsa); |
313 | } | ||
314 | memcpy(&dst, hp->h_addr, 4); | ||
315 | } | 313 | } |
316 | 314 | ||
317 | if (source && !inet_aton(source, &src)) { | 315 | if (source && !inet_aton(source, &src)) { |
diff --git a/networking/hostname.c b/networking/hostname.c index 6d3b8ebb8..7116a14df 100644 --- a/networking/hostname.c +++ b/networking/hostname.c | |||
@@ -48,11 +48,12 @@ int hostname_main(int argc, char **argv) | |||
48 | OPT_f = 0x2, | 48 | OPT_f = 0x2, |
49 | OPT_i = 0x4, | 49 | OPT_i = 0x4, |
50 | OPT_s = 0x8, | 50 | OPT_s = 0x8, |
51 | OPT_F = 0x8, | ||
51 | OPT_dfis = 0xf, | 52 | OPT_dfis = 0xf, |
52 | }; | 53 | }; |
53 | 54 | ||
54 | char buf[256]; | 55 | char buf[256]; |
55 | char *hostname_str = NULL; | 56 | char *hostname_str; |
56 | 57 | ||
57 | if (argc < 1) | 58 | if (argc < 1) |
58 | bb_show_usage(); | 59 | bb_show_usage(); |
@@ -70,7 +71,7 @@ int hostname_main(int argc, char **argv) | |||
70 | puts(hp->h_name); | 71 | puts(hp->h_name); |
71 | } else if (option_mask32 & OPT_s) { | 72 | } else if (option_mask32 & OPT_s) { |
72 | if (p != NULL) { | 73 | if (p != NULL) { |
73 | *p = 0; | 74 | *p = '\0'; |
74 | } | 75 | } |
75 | puts(hp->h_name); | 76 | puts(hp->h_name); |
76 | } else if (option_mask32 & OPT_d) { | 77 | } else if (option_mask32 & OPT_d) { |
@@ -84,7 +85,7 @@ int hostname_main(int argc, char **argv) | |||
84 | } | 85 | } |
85 | } | 86 | } |
86 | /* Set the hostname */ | 87 | /* Set the hostname */ |
87 | else if (hostname_str != NULL) { | 88 | else if (option_mask32 & OPT_F) { |
88 | do_sethostname(hostname_str, 1); | 89 | do_sethostname(hostname_str, 1); |
89 | } else if (optind < argc) { | 90 | } else if (optind < argc) { |
90 | do_sethostname(argv[optind], 0); | 91 | do_sethostname(argv[optind], 0); |