mirror of
https://github.com/ipxe/ipxe
synced 2026-02-14 02:31:26 +03:00
inet_aton doesn't overwrite the IP address unless it is valid.
This commit is contained in:
@@ -146,9 +146,8 @@ int strcasecmp(const char *a, const char *b)
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
INET_ATON - Convert an ascii x.x.x.x to binary form
|
INET_ATON - Convert an ascii x.x.x.x to binary form
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
int inet_aton(const char *start, in_addr *i)
|
int inet_aton ( const char *cp, struct in_addr *inp ) {
|
||||||
{
|
const char *p = cp;
|
||||||
const char *p = start;
|
|
||||||
const char *digits_start;
|
const char *digits_start;
|
||||||
unsigned long ip = 0;
|
unsigned long ip = 0;
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
@@ -160,8 +159,11 @@ int inet_aton(const char *start, in_addr *i)
|
|||||||
if ( ( j < 3 ) && ( *(p++) != '.' ) ) return 0;
|
if ( ( j < 3 ) && ( *(p++) != '.' ) ) return 0;
|
||||||
ip = (ip << 8) | val;
|
ip = (ip << 8) | val;
|
||||||
}
|
}
|
||||||
i->s_addr = htonl(ip);
|
if ( *p == '\0' ) {
|
||||||
return p - start;
|
inp->s_addr = htonl(ip);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long strtoul(const char *p, const char **endp, int base)
|
unsigned long strtoul(const char *p, const char **endp, int base)
|
||||||
|
|||||||
Reference in New Issue
Block a user