Repository navigation
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IPAddressV6::fromInverseArpaNamechecked only that the name has 32 labels, then used the first character of each label. A malformed name such asfe.0.0.(29 more).0.ip6.arpareturned::finstead 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.arpareturned2620:0:1cfe:face:b00c::3. The header says the function throwsIPAddressFormatExceptionfor 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
IPAddressFormatExceptionwhen a label is not exactly one character. Hex validity is still checked by theIPAddressV6parse 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
TEST(IPaddress, fromInverseArpaName)infolly/test/IPAddressTest.cpp. The30.case fails onmain@ 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.ctestrun. Clang and MSVC were not tried.clang-format(folly's.clang-format) reports no changes.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.