Fix validation of overly-long IPv6 addresses.
authorTom Lane <[email protected]>
Thu, 16 Jun 2016 21:16:32 +0000 (17:16 -0400)
committerTom Lane <[email protected]>
Thu, 16 Jun 2016 21:16:58 +0000 (17:16 -0400)
The inet/cidr types sometimes failed to reject IPv6 inputs with too many
colon-separated fields, instead translating them to '::/0'.  This is the
result of a thinko in the original ISC code that seems to be as yet
unreported elsewhere.  Per bug #14198 from Stefan Kaltenbrunner.

Report: <20160616182222[email protected]>

src/backend/utils/adt/inet_net_pton.c

index 1d32d2f04f6121bd0a56ebc58f4ecb7a055ecf59..20e6efe74951cac4042ac116966667b1b2dce93a 100644 (file)
@@ -495,7 +495,7 @@ inet_cidr_pton_ipv6(const char *src, u_char *dst, size_t size)
            else if (*src == '\0')
                goto enoent;
            if (tp + NS_INT16SZ > endp)
-               return (0);
+               goto enoent;
            *tp++ = (u_char) (val >> 8) & 0xff;
            *tp++ = (u_char) val & 0xff;
            saw_xdigit = 0;