Page MenuHomeFreeBSD

inet_net_pton: Always copy out the full address
Needs ReviewPublic

Authored by ivy on Thu, Oct 30, 10:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 31, 2:08 PM
Unknown Object (File)
Fri, Oct 31, 3:56 AM
Unknown Object (File)
Fri, Oct 31, 3:29 AM
Unknown Object (File)
Fri, Oct 31, 3:21 AM
Unknown Object (File)
Fri, Oct 31, 3:01 AM
Unknown Object (File)
Fri, Oct 31, 2:49 AM
Subscribers

Details

Reviewers
des
Group Reviewers
network
Summary

Previously, in the AF_INET6 case, inet_net_pton() would only copy out
the part of the address covered by the provided prefix length. For
example, if the input address was "2001:db8::1/32", it would only
copy out 4 bytes of the address.

This causes two problems. Firstly, this means the caller has to zero
the provided buffer before calling inet_net_pton(), which is neither
expected nor documented in the manual page.

Secondly, it means that with an input like "2001:db8::1/32", the
last bit of the address would not be copied out, so the result would
be "2001:db8::" instead of "2001:db8::1". This differs from the IPv4
behaviour, where the entire address is always copied out.

Fix this by always copying out the full address, and adjust the tests
to handle this.

MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 68302
Build 65185: arc lint + arc unit