inet_net_pton.c.patch   [plain text]


--- inet_net_pton.c.orig	2008-09-01 22:59:17.000000000 -0700
+++ inet_net_pton.c	2008-09-01 23:00:34.000000000 -0700
@@ -18,6 +18,10 @@
 #if defined(LIBC_SCCS) && !defined(lint)
 static const char rcsid[] = "$Id: inet_net_pton.c,v 1.7.18.1 2005/04/27 05:00:53 sra Exp $";
 #endif
+
+/* the algorithms only can deal with ASCII, so we optimize for it */
+#define USE_ASCII
+
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libc/inet/inet_net_pton.c,v 1.3 2007/06/03 17:20:26 ume Exp $");
 
@@ -135,11 +139,11 @@ inet_net_pton_ipv4(const char *src, u_ch
 			assert(n >= 0 && n <= 9);
 			bits *= 10;
 			bits += n;
+			if (bits > 32)
+				goto emsgsize;
 		} while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
 		if (ch != '\0')
 			goto enoent;
-		if (bits > 32)
-			goto emsgsize;
 	}
 
 	/* Firey death and destruction unless we prefetched EOS. */