summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMichael Brown2005-04-30 15:50:34 +0200
committerMichael Brown2005-04-30 15:50:34 +0200
commit903ddd98785ca091a8995db4e69a722855ebd337 (patch)
tree5727eed5de0803da7ccb7c6fbe0c21655b4c88c8 /src/core
parentProtocols also take a pointer to a sockaddr_in. (diff)
downloadipxe-903ddd98785ca091a8995db4e69a722855ebd337.tar.gz
ipxe-903ddd98785ca091a8995db4e69a722855ebd337.tar.xz
ipxe-903ddd98785ca091a8995db4e69a722855ebd337.zip
inet_aton doesn't overwrite the IP address unless it is valid.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/misc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
index 0fe6cb47d..22930fcf0 100644
--- a/src/core/misc.c
+++ b/src/core/misc.c
@@ -146,9 +146,8 @@ int strcasecmp(const char *a, const char *b)
/**************************************************************************
INET_ATON - Convert an ascii x.x.x.x to binary form
**************************************************************************/
-int inet_aton(const char *start, in_addr *i)
-{
- const char *p = start;
+int inet_aton ( const char *cp, struct in_addr *inp ) {
+ const char *p = cp;
const char *digits_start;
unsigned long ip = 0;
unsigned long val;
@@ -160,8 +159,11 @@ int inet_aton(const char *start, in_addr *i)
if ( ( j < 3 ) && ( *(p++) != '.' ) ) return 0;
ip = (ip << 8) | val;
}
- i->s_addr = htonl(ip);
- return p - start;
+ if ( *p == '\0' ) {
+ inp->s_addr = htonl(ip);
+ return 1;
+ }
+ return 0;
}
unsigned long strtoul(const char *p, const char **endp, int base)