DragonFly submit List (threaded) for 2007-03
DragonFly BSD
DragonFly submit List (threaded) for 2007-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

inet_pton(3) patch


From: Tatsuya BIZENN <bizenn@xxxxxxxxx>
Date: Sun, 25 Mar 2007 23:33:06 +0900

DragonFly's inet_pton(3) accepts also invalid IPv6 address form string.
I think it should be applied this patch below.  So inet_pton(3) become
the same one with NetBSD(it works properly).

--
Tatsuya BIZENN


Index: lib/libc/net/inet_pton.c =================================================================== RCS file: /dcvs/src/lib/libc/net/inet_pton.c,v retrieving revision 1.4 diff -u -r1.4 inet_pton.c --- lib/libc/net/inet_pton.c 13 Nov 2005 02:04:47 -0000 1.4 +++ lib/libc/net/inet_pton.c 24 Mar 2007 14:34:31 -0000 @@ -88,6 +88,8 @@ 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; @@ -164,7 +166,8 @@ return (0); colonp = tp; continue; - } + } else if (*src == '\0') + return (0); if (tp + NS_INT16SZ > endp) return (0); *tp++ = (u_char) (val >> 8) & 0xff; @@ -195,6 +198,8 @@ 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;





[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]