From f73c8fffeea21e69f9c48473c088d1941ca3f1ab Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 16 Jul 2001 03:31:45 +0000 Subject: [PATCH] pullup from BIND 8: 1242. [bug] inet_pton() failed to reject octal input. --- lib/bind/inet/inet_pton.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/bind/inet/inet_pton.c b/lib/bind/inet/inet_pton.c index 6939843456..6135025428 100644 --- a/lib/bind/inet/inet_pton.c +++ b/lib/bind/inet/inet_pton.c @@ -16,7 +16,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "$Id: inet_pton.c,v 1.1 2001/03/29 06:31:41 marka Exp $"; +static const char rcsid[] = "$Id: inet_pton.c,v 1.2 2001/07/16 03:31:45 marka Exp $"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -95,10 +95,12 @@ inet_pton4(src, 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; - if (! saw_digit) { + if (!saw_digit) { if (++octets > 4) return (0); saw_digit = 1;