Prevent an overflow in inet_net_pton(3) when the passed in buffer is
authorflorian <florian@openbsd.org>
Tue, 19 Jan 2021 16:43:44 +0000 (16:43 +0000)
committerflorian <florian@openbsd.org>
Tue, 19 Jan 2021 16:43:44 +0000 (16:43 +0000)
commit73159aebc3abfb2b38a6bde8cc4c693d93b287f9
tree20324678a4ade69837454889234804a05e3f8fa3
parent222f252fd9487b6bd9d7ef3ea93475a2a30b49e8
Prevent an overflow in inet_net_pton(3) when the passed in buffer is
too small in the AF_INET6 case.
Spotted by Brad House (brad AT brad-house.com) with the c-ares
regression test.

The man page says
     Caution: The dst field should be zeroed before calling inet_net_pton() as
     the function will only fill the number of bytes necessary to encode the
     network number in network byte order.

Which seems to suggest that the function should work if the passed in
storage is big enough to hold the prefix, which might be smaller than
sizeof(in6_addr).

Input & OK tb
lib/libc/net/inet_net_pton.c