Report the whole fe80::/10 range from Address6.isLinkLocal() - #223
Closed
spokodev wants to merge 2 commits into
Closed
Report the whole fe80::/10 range from Address6.isLinkLocal()#223spokodev wants to merge 2 commits into
spokodev wants to merge 2 commits into
Conversation
isLinkLocal() only returned true for fe80::/64 with an all-zero
interface prefix, so fe80:1::1, fe90::1, fea0::1 and febf::1 all read
as non-link-local even though getType() classifies the same addresses
as 'Link-local unicast' via isHostInSubnet('fe80::/10'). The stale
comment claiming isHostInSubnet can't be used for fe80::/10 was
disproven by getType() already doing exactly that.
Match getType() by testing membership in fe80::/10. fec0::1 and global
addresses are unaffected, and the change is a strict superset of the
previous result.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #223 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 370 373 +3
Branches 216 218 +2
=========================================
+ Hits 370 373 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
|
Thanks, and sorry for the overlap: the same fix shipped in 10.5.1 through GHSA-rpw4-54j3-4h4q, which was filed a few days after you opened this. Closing as superseded. |
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.
Address6.isLinkLocal()under-reports the IANA link-local rangefe80::/10. It returnstrueonly when the interface-prefix bits (10–63) are all zero, i.e.fe80::/64, so every other address in the range reads as non-link-local:This contradicts the library's own
getType(), which already classifies all of those asLink-local unicast:getType()reaches that verdict throughisHostInSubnet('fe80::/10'), so the inline comment onisLinkLocal()— "we can't check isHostInSubnet with 'fe80::/10'" — is not accurate.The fix
Replace the hard-coded 64-bit prefix compare with
isHostInSubnet(LINK_LOCAL_UNICAST_SUBNET), mirroringgetType()and the sibling predicates (isULA()usesisHostInSubnet(ULA_SUBNET)). Thefe80::/10subnet is added to the existing block of module-level subnet constants. The IPv4-mapped delegation at the top of the method is preserved.The change is a strict superset of the previous behaviour: every input that returned
truestill returnstrue,fec0::1(site-local) and global addresses stayfalse.History
getScope()/getType()were broadened to the fullfe80::/10in #200 (closing #122), and the boolean predicates were added in #197, butisLinkLocal()kept its narrowerfe80::/64check, so the two have disagreed since. This aligns them.Tests
Added a case in the existing
isLinkLocalblock asserting the wholefe80::/10range (including a zone-id form) reportstrueand matchesgetType(), plus a negativefec0::1. Fails before the change, passes after; full suite3595 passing.