This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
the inet_network() function currently returns 0 for "0x" rather than INADDR_NONE. attached patch fixes that by resetting digit to 0 thus forcing subsequent parsing to get digit to be 1. -mike
Attachment:
signature.asc
Description: This is a digitally signed message part.
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".
Index: inet/inet_net.c
===================================================================
RCS file: /cvs/glibc/libc/inet/inet_net.c,v
retrieving revision 1.10
diff -u -p -r1.10 inet_net.c
--- inet/inet_net.c 12 Feb 2000 07:38:04 -0000 1.10
+++ inet/inet_net.c 15 Sep 2007 06:14:59 -0000
@@ -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'))
Index: inet/tst-network.c
===================================================================
RCS file: /cvs/glibc/libc/inet/tst-network.c,v
retrieving revision 1.4
diff -u -p -r1.4 tst-network.c
--- inet/tst-network.c 15 Sep 2007 04:10:38 -0000 1.4
+++ inet/tst-network.c 15 Sep 2007 06:14:59 -0000
@@ -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},
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |