From a7e5b19f4c09ee6646e545d0c3db797352224a4a Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sat, 27 Dec 2008 02:54:03 +0000 Subject: [PATCH] - Lets try this again. Re-implement inet_aton so that it does not fail in 255.255.255.255. See bug 3962 for more info. svn path=/trunk/; revision=38364 --- reactos/base/services/dhcp/compat.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/reactos/base/services/dhcp/compat.c b/reactos/base/services/dhcp/compat.c index ec132ca360a..83c9c12ea8c 100644 --- a/reactos/base/services/dhcp/compat.c +++ b/reactos/base/services/dhcp/compat.c @@ -32,11 +32,36 @@ u_int32_t arc4random() int inet_aton(const char *cp, struct in_addr *inp) +/* inet_addr code from ROS, slightly modified. */ { - inp->S_un.S_addr = inet_addr(cp); - if (INADDR_NONE == inp->S_un.S_addr) + ULONG Octets[4] = {0,0,0,0}; + ULONG i = 0; + + if(!cp) return 0; + while(*cp) + { + CHAR c = *cp; + cp++; + + if(c == '.') + { + i++; + continue; + } + + if(c < '0' || c > '9') + return 0; + + Octets[i] *= 10; + Octets[i] += (c - '0'); + + if(Octets[i] > 255) + return 0; + } + + inp->S_un.S_addr = (Octets[3] << 24) + (Octets[2] << 16) + (Octets[1] << 8) + Octets[0]; return 1; }