X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=networking%2Fifconfig.c;h=4e3df2982cfa7e57a8a943de4b5b1d16cb68c913;hb=4872ed9737c1349aec2f41b1b8a905a9158da5c1;hp=63d88bc2c8995de39fb313e84e8c07858df55741;hpb=0cc7e6236a897cb09a78b61a21d2c16ad423f4ce;p=oweals%2Fbusybox.git diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 63d88bc2c..4e3df2982 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c @@ -6,7 +6,7 @@ * Bjorn Wesen, Axis Communications AB * * - * Authors of the original ifconfig was: + * Authors of the original ifconfig was: * Fred N. van Kempen, * * This program is free software; you can redistribute it @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: ifconfig.c,v 1.25 2003/06/20 09:23:34 andersen Exp $ + * $Id: ifconfig.c,v 1.30 2004/03/31 11:30:08 andersen Exp $ * */ @@ -37,6 +37,7 @@ #include /* strcmp and friends */ #include /* isdigit and friends */ #include /* offsetof */ +#include #include #include #include @@ -163,7 +164,7 @@ struct in6_ifreq { #define ARG_NETMASK (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_NETMASK) #define ARG_BROADCAST (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_BROADCAST) #define ARG_HW (A_ARG_REQ | A_CAST_HOST_COPY_IN_ETHER) -#define ARG_POINTOPOINT (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER) +#define ARG_POINTOPOINT (A_ARG_REQ | A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER) #define ARG_KEEPALIVE (A_ARG_REQ | A_CAST_CHAR_PTR) #define ARG_OUTFILL (A_ARG_REQ | A_CAST_CHAR_PTR) #define ARG_HOSTNAME (A_CAST_HOST_COPY_RESOLVE | A_SET_AFTER | A_COLON_CHK | A_HOSTNAME) @@ -306,8 +307,10 @@ int ifconfig_main(int argc, char **argv) goterr = 0; did_flags = 0; +#ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS sai_hostname = 0; sai_netmask = 0; +#endif /* skip argv[0] */ ++argv; @@ -392,8 +395,9 @@ int ifconfig_main(int argc, char **argv) safe_strncpy(host, *argv, (sizeof host)); #ifdef CONFIG_FEATURE_IPV6 if ((prefix = strchr(host, '/'))) { - prefix_len = atol(prefix + 1); - if ((prefix_len < 0) || (prefix_len > 128)) { + if (safe_strtoi(prefix + 1, &prefix_len) || + (prefix_len < 0) || (prefix_len > 128)) + { ++goterr; goto LOOP; } @@ -440,8 +444,13 @@ int ifconfig_main(int argc, char **argv) #endif } else if (inet_aton(host, &sai.sin_addr) == 0) { /* It's not a dotted quad. */ - ++goterr; - continue; + struct hostent *hp; + if ((hp = gethostbyname(host)) == (struct hostent *)NULL) { + ++goterr; + continue; + } + memcpy((char *) &sai.sin_addr, (char *) hp->h_addr_list[0], + sizeof(struct in_addr)); } #ifdef CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS if (mask & A_HOSTNAME) { @@ -507,7 +516,7 @@ int ifconfig_main(int argc, char **argv) * a - at the end, since it's deleted already! - Roman * * Should really use regex.h here, not sure though how well - * it'll go with the cross-platform support etc. + * it'll go with the cross-platform support etc. */ char *ptr; short int found_colon = 0;