aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libbb.h2
-rw-r--r--networking/ifconfig.c53
-rw-r--r--networking/traceroute.c2
3 files changed, 28 insertions, 29 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 742d04031..d22efe05b 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -344,7 +344,7 @@ char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa, socklen_t sale
344char* xmalloc_sockaddr2dotted(const struct sockaddr *sa, socklen_t salen); 344char* xmalloc_sockaddr2dotted(const struct sockaddr *sa, socklen_t salen);
345char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa, socklen_t salen); 345char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa, socklen_t salen);
346// "old" (ipv4 only) API 346// "old" (ipv4 only) API
347// users: traceroute.c hostname.c ifconfig.c ping.c 347// users: traceroute.c hostname.c
348struct hostent *xgethostbyname(const char *name); 348struct hostent *xgethostbyname(const char *name);
349 349
350 350
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
index b36f86d6a..f4fc0a476 100644
--- a/networking/ifconfig.c
+++ b/networking/ifconfig.c
@@ -266,9 +266,6 @@ int ifconfig_main(int argc, char **argv)
266{ 266{
267 struct ifreq ifr; 267 struct ifreq ifr;
268 struct sockaddr_in sai; 268 struct sockaddr_in sai;
269#if ENABLE_FEATURE_IPV6
270 struct sockaddr_in6 sai6;
271#endif
272#if ENABLE_FEATURE_IFCONFIG_HW 269#if ENABLE_FEATURE_IFCONFIG_HW
273 struct sockaddr sa; 270 struct sockaddr sa;
274#endif 271#endif
@@ -389,31 +386,33 @@ int ifconfig_main(int argc, char **argv)
389 sai.sin_addr.s_addr = (~sai_netmask) | (sai_hostname & sai_netmask); 386 sai.sin_addr.s_addr = (~sai_netmask) | (sai_hostname & sai_netmask);
390 } 387 }
391#endif 388#endif
389 else {
390 len_and_sockaddr *lsa = xhost2sockaddr(host, 0);
392#if ENABLE_FEATURE_IPV6 391#if ENABLE_FEATURE_IPV6
393 else if (inet_pton(AF_INET6, host, &sai6.sin6_addr) > 0) { 392 if (lsa->sa.sa_family == AF_INET6) {
394 int sockfd6; 393 int sockfd6;
395 struct in6_ifreq ifr6; 394 struct in6_ifreq ifr6;
396 395
397 memcpy((char *) &ifr6.ifr6_addr, 396 memcpy((char *) &ifr6.ifr6_addr,
398 (char *) &sai6.sin6_addr, 397 (char *) &(lsa->sin6.sin6_addr),
399 sizeof(struct in6_addr)); 398 sizeof(struct in6_addr));
400 399
401 /* Create a channel to the NET kernel. */ 400 /* Create a channel to the NET kernel. */
402 sockfd6 = xsocket(AF_INET6, SOCK_DGRAM, 0); 401 sockfd6 = xsocket(AF_INET6, SOCK_DGRAM, 0);
403 if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) 402 if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0)
404 bb_perror_msg_and_die("SIOGIFINDEX"); 403 bb_perror_msg_and_die("SIOGIFINDEX");
405 ifr6.ifr6_ifindex = ifr.ifr_ifindex; 404 ifr6.ifr6_ifindex = ifr.ifr_ifindex;
406 ifr6.ifr6_prefixlen = prefix_len; 405 ifr6.ifr6_prefixlen = prefix_len;
407 if (ioctl(sockfd6, a1op->selector, &ifr6) < 0) 406 if (ioctl(sockfd6, a1op->selector, &ifr6) < 0)
408 bb_perror_msg_and_die(a1op->name); 407 bb_perror_msg_and_die(a1op->name);
409 continue; 408 if (ENABLE_FEATURE_CLEAN_UP)
410 } 409 free(lsa);
411#endif 410 continue;
412 else if (inet_aton(host, &sai.sin_addr) == 0) { 411 }
413 /* It's not a dotted quad. */ 412#endif
414 struct hostent *hp = xgethostbyname(host); 413 sai.sin_addr = lsa->sin.sin_addr;
415 memcpy((char *) &sai.sin_addr, (char *) hp->h_addr_list[0], 414 if (ENABLE_FEATURE_CLEAN_UP)
416 sizeof(struct in_addr)); 415 free(lsa);
417 } 416 }
418#if ENABLE_FEATURE_IFCONFIG_BROADCAST_PLUS 417#if ENABLE_FEATURE_IFCONFIG_BROADCAST_PLUS
419 if (mask & A_HOSTNAME) 418 if (mask & A_HOSTNAME)
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 4ddde2fda..fd4c20e6d 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -247,7 +247,7 @@ struct ipovly {
247/* 247/*
248 * UDP kernel structures and variables. 248 * UDP kernel structures and variables.
249 */ 249 */
250struct udpiphdr { 250struct udpiphdr {
251 struct ipovly ui_i; /* overlaid ip structure */ 251 struct ipovly ui_i; /* overlaid ip structure */
252 struct udphdr ui_u; /* udp header */ 252 struct udphdr ui_u; /* udp header */
253}; 253};