[ros-diffs] [mjmartin] 38364: - 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.

mjmartin at svn.reactos.org mjmartin at svn.reactos.org
Sat Dec 27 03:54:04 CET 2008


Author: mjmartin
Date: Fri Dec 26 20:54:03 2008
New Revision: 38364

URL: http://svn.reactos.org/svn/reactos?rev=38364&view=rev
Log:
- 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.

Modified:
    trunk/reactos/base/services/dhcp/compat.c

Modified: trunk/reactos/base/services/dhcp/compat.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/dhcp/compat.c?rev=38364&r1=38363&r2=38364&view=diff
==============================================================================
--- trunk/reactos/base/services/dhcp/compat.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/dhcp/compat.c [iso-8859-1] Fri Dec 26 20:54:03 2008
@@ -32,11 +32,36 @@
 
 
 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;
 }
 



More information about the Ros-diffs mailing list