From ca8316b8dd70d583004789919db2eb8cc4720940 Mon Sep 17 00:00:00 2001 From: ume Date: Wed, 27 Jul 2005 14:33:36 +0000 Subject: don't accept invalid form of an address like 1:2:3:4:5:6:7::8. PR: bin/84106 Obtained from: BIND9 MFC after: 2 days --- lib/libc/net/inet_pton.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/libc/net/inet_pton.c') diff --git a/lib/libc/net/inet_pton.c b/lib/libc/net/inet_pton.c index 65f28cf..78dbf44 100644 --- a/lib/libc/net/inet_pton.c +++ b/lib/libc/net/inet_pton.c @@ -88,6 +88,8 @@ inet_pton4(const char *src, u_char *dst) if ((pch = strchr(digits, ch)) != NULL) { u_int new = *tp * 10 + (pch - digits); + if (saw_digit && *tp == 0) + return (0); if (new > 255) return (0); *tp = new; @@ -195,6 +197,8 @@ inet_pton6(const char *src, u_char *dst) const int n = tp - colonp; int i; + if (tp == endp) + return (0); for (i = 1; i <= n; i++) { endp[- i] = colonp[n - i]; colonp[n - i] = 0; -- cgit v1.1