Skip to content

Reject multi-character labels in IPAddressV6::fromInverseArpaName - #2747

Open
0z5a wants to merge 1 commit into
meta:mainfrom
0z5a:fix/ipv6-arpa-label-length
Open

0z5a wants to merge 1 commit into
meta:mainfrom
0z5a:fix/ipv6-arpa-label-length

Conversation

@0z5a

@0z5a 0z5a commented Nov 13, 2026

Copy link
Copy Markdown

Summary

IPAddressV6::fromInverseArpaName checked only that the name has 32 labels, then used the first character of each label. A malformed name such as fe.0.0.(29 more).0.ip6.arpa returned ::f instead of throwing. 30.0.0.0.0.0.0.0.0.0.0.0.c.0.0.b.e.c.a.f.e.f.c.1.0.0.0.0.0.2.6.2.ip6.arpa returned 2620:0:1cfe:face:b00c::3. The header says the function throws IPAddressFormatException for input that is not a valid ip6.arpa representation. In ip6.arpa every label is one hex digit (RFC 3596, section 2.5).

This change throws IPAddressFormatException when a label is not exactly one character. Hex validity is still checked by the IPAddressV6 parse at the end. The change also stops reading [0] of an empty label, which previously threw only because the byte after it happened to be a ..

Fixes #2745

Validation

  • Added two cases to the existing TEST(IPaddress, fromInverseArpaName) in folly/test/IPAddressTest.cpp. The 30. case fails on main @ 4a2f75a ("it throws nothing") and passes with this change. The empty-label case passes on both and covers the new check.
  • network_address_test (IPAddressTest.cpp, MacAddressTest.cpp, SocketAddressTest.cpp; all 535 tests) passes. It was built with the CMake build (-DBUILD_TESTS=ON -DBUILD_HANGING_TESTS=ON, RelWithDebInfo) and GCC 13.3 on x86_64 Linux.
  • This was a build of that target only, not a full ctest run. Clang and MSVC were not tried.
  • clang-format (folly's .clang-format) reports no changes.
  • The branch is rebased onto main @ 7014db8. Neither touched file changed upstream between the two commits, so the tests were not re-run after the rebase.

This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.

fromInverseArpaName checked only that the name has 32 labels and then
used the first character of each label, so a label such as "fe" was
read as "f": "fe.0.0.(29 more).0.ip6.arpa" returned ::f instead of
throwing. In ip6.arpa names each nibble is one label (RFC 3596,
section 2.5), and the header documents IPAddressFormatException for
input that is not a valid ip6.arpa representation.

Throw when a label is not exactly one character. This also avoids
reading the first character of an empty label.
@meta-cla meta-cla Bot added the CLA Signed label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPAddressV6::fromInverseArpaName accepts multi-character labels and keeps only their first character

1 participant