summary refs log tree commit diff
path: root/inet/inet_net.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-01-31 08:22:01 +0000
committerUlrich Drepper <drepper@redhat.com>2000-01-31 08:22:01 +0000
commit613444ea7cee5badcf057b93e896b51e9cb74c0a (patch)
treec36907057166403e292c153f14bd4dd9b2c64fd3 /inet/inet_net.c
parent8a94dfe44e23e89b366019c9b4cad1a3cc1d853b (diff)
downloadglibc-613444ea7cee5badcf057b93e896b51e9cb74c0a.tar.gz
glibc-613444ea7cee5badcf057b93e896b51e9cb74c0a.tar.xz
glibc-613444ea7cee5badcf057b93e896b51e9cb74c0a.zip
(inet_network): Synch with bind 8.2.2.
Diffstat (limited to 'inet/inet_net.c')
-rw-r--r--inet/inet_net.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/inet/inet_net.c b/inet/inet_net.c
index 532d8211ea..cdc4d9dd96 100644
--- a/inet/inet_net.c
+++ b/inet/inet_net.c
@@ -48,28 +48,35 @@ inet_network(cp)
 	register u_int32_t val, base, n, i;
 	register char c;
 	u_int32_t parts[4], *pp = parts;
+	int digit;
 
 again:
-	val = 0; base = 10;
+	val = 0; base = 10; digit = 0;
 	if (*cp == '0')
-		base = 8, cp++;
+		digit = 1, base = 8, cp++;
 	if (*cp == 'x' || *cp == 'X')
 		base = 16, cp++;
-	while ((c = *cp)) {
+	while ((c = *cp) != 0) {
 		if (isdigit(c)) {
+			if (base == 8 && (c == '8' || c == '9'))
+				return (INADDR_NONE);
 			val = (val * base) + (c - '0');
 			cp++;
+			digit = 1;
 			continue;
 		}
 		if (base == 16 && isxdigit(c)) {
 			val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
 			cp++;
+			digit = 1;
 			continue;
 		}
 		break;
 	}
+	if (!digit)
+		return (INADDR_NONE);
 	if (*cp == '.') {
-		if (pp >= parts + 4)
+		if (pp >= parts + 4 || val > 0xff)
 			return (INADDR_NONE);
 		*pp++ = val, cp++;
 		goto again;