Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 2003d1abfa0c20ee77815f0da33e2c1c > files > 103

glibc-2.5-49.el5_5.5.src.rpm

2007-09-15  Mike Frysinger  <vapier@gentoo.org>

	* inet/inet_net.c: Reset digit to 0 for inputs starting with "0x".
	* inet/tst-network.c (tests): Add edge case tests for "0", "0x", "0x0".

2007-09-14  Mike Frysinger  <vapier@gentoo.org>

	* inet/tst-network.c: Increment ERRORS for failing tests.

--- libc/inet/inet_net.c	12 Feb 2000 07:38:04 -0000	1.10
+++ libc/inet/inet_net.c	15 Sep 2007 22:21:19 -0000	1.11
@@ -55,7 +55,7 @@ again:
 	if (*cp == '0')
 		digit = 1, base = 8, cp++;
 	if (*cp == 'x' || *cp == 'X')
-		base = 16, cp++;
+		digit = 0, base = 16, cp++;
 	while ((c = *cp) != 0) {
 		if (isdigit(c)) {
 			if (base == 8 && (c == '8' || c == '9'))
--- libc/inet/tst-network.c	24 Sep 2002 04:21:03 -0000	1.3
+++ libc/inet/tst-network.c	18 Sep 2007 17:56:37 -0000	1.5
@@ -34,7 +34,10 @@ struct
   {"1.0", 0x100},
   {"1", 0x1},
   {"192.168.0.0", 0xC0A80000},
+  {"0", 0},
+  {"0x0", 0},
   /* Now some invalid addresses.  */
+  {"0x", INADDR_NONE},
   {"141.30.225.2800", INADDR_NONE},
   {"141.76.1.1.1", INADDR_NONE},
   {"141.76.1.11.", INADDR_NONE},
@@ -61,6 +64,7 @@ main (void)
 
       if (res != tests[i].number)
 	{
+	  ++errors;
 	  printf ("Test failed for inet_network (\"%s\"):\n",
 		  tests[i].network);
 	  printf ("Expected return value %u (0x%x) but got %u (0x%x).\n",