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]

[PATCH][BZ #15277] Fix inet_network("1 bar")


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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]