Skip to content

fix: leave IP host numbers unchanged when they do not fit - #50

Closed
SashaMIT wants to merge 1 commit into
PuerkitoBio:masterfrom
SashaMIT:fix/host-integer-range
Closed

SashaMIT wants to merge 1 commit into
PuerkitoBio:masterfrom
SashaMIT:fix/host-integer-range

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 2, 2026 •

Copy link
Copy Markdown

Summary

  • FlagDecodeOctalHost turned 08.00.00.01 into 0.0.0.1 because strconv.ParseInt rejects digit 8 and the error was discarded. 0400.0000.0000.0001 became 256.0.0.1.
  • FlagDecodeDWORDHost turned 4294967296 into 0.0.0.0, and an integer past int64 into 255.255.255.255 the same way. FlagDecodeHexHost did the same for 0x100000000.
  • Those hosts are left unchanged. Values that fit still decode: 1113982867 is 66.102.7.147, 4294967295 is 255.255.255.255, and 0102.0146.07.0223 is 66.102.7.147.

Test plan

  • go test ./...

Parse errors and values outside an octet or a uint32 were discarded, so the host was rewritten as a different address.
@JohnTitor JohnTitor closed this Oct 3, 2026
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.

2 participants