about summary refs log tree commit diff
path: root/src/network
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-10-19 22:36:30 -0400
committerRich Felker <dalias@aerifal.cx>2013-10-19 22:36:30 -0400
commit38b9c0274974a1b9941adb2e59238b153704151f (patch)
tree0fd11ed0d81ed1d3cbd4d8c2c6cc4e3ed073c7db /src/network
parentebb4cc0fec110edc7caf5ae545bfb816565a060d (diff)
downloadmusl-38b9c0274974a1b9941adb2e59238b153704151f.tar.gz
musl-38b9c0274974a1b9941adb2e59238b153704151f.tar.xz
musl-38b9c0274974a1b9941adb2e59238b153704151f.zip
fix return value for inet_pton in ipv6 failure cases
in the case of input that does not match the expected form, the
correct return value is 0, not -1.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/inet_pton.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/network/inet_pton.c b/src/network/inet_pton.c
index 5c4850a6..8f7c17b5 100644
--- a/src/network/inet_pton.c
+++ b/src/network/inet_pton.c
@@ -46,24 +46,24 @@ int inet_pton(int af, const char *restrict s, void *restrict a0)
 			if (!s[1]) break;
 			continue;
 		}
-		if (hexval(s[0])<0) return -1;
+		if (hexval(s[0])<0) return 0;
 		while (s[0]=='0' && s[1]=='0') s++;
 		for (v=j=0; j<5 && (d=hexval(s[j]))>=0; j++)
 			v=16*v+d;
-		if (v > 65535) return -1;
+		if (v > 65535) return 0;
 		ip[i] = v;
 		if (!s[j]) {
-			if (brk<0 && i!=7) return -1;
+			if (brk<0 && i!=7) return 0;
 			break;
 		}
 		if (i<7) {
 			if (s[j]==':') continue;
-			if (s[j]!='.') return -1;
+			if (s[j]!='.') return 0;
 			need_v4=1;
 			i++;
 			break;
 		}
-		return -1;
+		return 0;
 	}
 	if (brk>=0) {
 		memmove(ip+brk+7-i, ip+brk, 2*(i+1-brk));
@@ -73,6 +73,6 @@ int inet_pton(int af, const char *restrict s, void *restrict a0)
 		*a++ = ip[j]>>8;
 		*a++ = ip[j];
 	}
-	if (need_v4 &&inet_pton(AF_INET, (void *)s, a-4) <= 0) return -1;
+	if (need_v4 && inet_pton(AF_INET, (void *)s, a-4) <= 0) return 0;
 	return 1;
 }