This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH][BZ #15277] Fix inet_network("1 bar")
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Tue, 8 Oct 2013 21:13:31 +0200
- Subject: [PATCH][BZ #15277] Fix inet_network("1 bar")
- Authentication-results: sourceware.org; auth=none
Hi,
Here we do not detect that address is invalid as code only checked if
first byte after address is space. This patch checks rest of string for
nonspace characters.
Author of this bug added several cases to testcase, should we include
them or just 1 bar one.
https://sourceware.org/bugzilla/show_bug.cgi?id=15277
[BZ #15277]
* inet/inet_net.c (inet_network): Properly detect invalid strings.
diff --git a/inet/inet_net.c b/inet/inet_net.c
index 68e232f..85ce6b3 100644
--- a/inet/inet_net.c
+++ b/inet/inet_net.c
@@ -81,7 +81,9 @@ again:
*pp++ = val, cp++;
goto again;
}
- if (*cp && !isspace(*cp))
+ while (isspace(*cp))
+ cp++;
+ if (*cp)
return (INADDR_NONE);
if (pp >= parts + 4 || val > 0xff)
return (INADDR_NONE);