Skip to content

Reject IPv6 addresses as IPv4 masks - #524

Merged
tomasaschan merged 1 commit into
spf13:masterfrom
yuefdev:fix/ipv4-mask-address-family-sol
Oct 19, 2026
Merged

tomasaschan merged 1 commit into
spf13:masterfrom
yuefdev:fix/ipv4-mask-address-family-sol

Conversation

@yuefdev

@yuefdev yuefdev commented Oct 18, 2026

Copy link
Copy Markdown

Hi! ParseIPv4Mask("2001:db8::1") currently succeeds as 00000001: it takes the last four bytes of any IP address. Consequently, an IPv6 value silently changes an IPMask flag instead of returning a parse error.

Require To4() before constructing the mask. Keep dotted IPv4, hexadecimal masks and IPv4-mapped addresses working, and leave the flag unchanged after invalid input.

Both new regression tests failed before the fix. go test ./... -count=1, go vet ./... and gofmt pass on Windows/Go 1.27.

@CLAassistant

CLAassistant commented Oct 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@tomasaschan
tomasaschan merged commit f8b3686 into spf13:master Oct 19, 2026
7 of 8 checks passed
@tomasaschan

Copy link
Copy Markdown
Collaborator

Merged despite the failing lint check; that should have been addresed by #525. If not, I'll follow up with a fix after the main branch build fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants