Page MenuHomeFreeBSD

inet_net_pton: Always copy out the full address
Needs ReviewPublic

Authored by ivy on Oct 30 2025, 10:27 PM.
Tags
None
Referenced Files
F140064397: D53491.diff
Fri, Dec 19, 6:15 PM
Unknown Object (File)
Thu, Dec 18, 5:07 AM
Unknown Object (File)
Sun, Dec 14, 11:32 AM
Unknown Object (File)
Wed, Dec 10, 5:33 PM
Unknown Object (File)
Wed, Dec 3, 4:58 PM
Unknown Object (File)
Fri, Nov 28, 11:15 PM
Unknown Object (File)
Thu, Nov 27, 3:06 PM
Unknown Object (File)
Thu, Nov 27, 5:33 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

Event Timeline

ivy requested review of this revision.Oct 30 2025, 10:27 PM

This isn't intended to land in 15.0 any more, right?

This isn't intended to land in 15.0 any more, right?

correct.