Skip to content

Fix numeric strings being misinterpreted as binary strings#81

Open
bpbp-boop wants to merge 1 commit into
rlanvin:masterfrom
bpbp-boop:fix-issue-74-numeric-string-plus
Open

Fix numeric strings being misinterpreted as binary strings#81
bpbp-boop wants to merge 1 commit into
rlanvin:masterfrom
bpbp-boop:fix-issue-74-numeric-string-plus

Conversation

@bpbp-boop

Copy link
Copy Markdown

IPBlock iteration passes the position to IP::plus() as a decimal string. The IPv4 constructor's auto-detection treats any 4-character string as a packed binary string, so once the position reached 1000 the string "1000" was read as the bytes 0x31303030 (825241648) instead of the number 1000, yielding addresses far outside the block.

IP::plus() and IP::minus() now convert digit-only strings with initGmpFromNumericString() instead of the auto-detecting constructor, and IPBlock::getIterator() passes the GMP position directly.

Fixes #74

…s/minus

IPBlock iteration passes the position to IP::plus() as a decimal string.
The IPv4 constructor's auto-detection treats any 4-character string as a
packed binary string, so once the position reached 1000 the string "1000"
was read as the bytes 0x31303030 (825241648) instead of the number 1000,
yielding addresses far outside the block.

IP::plus() and IP::minus() now convert digit-only strings with
initGmpFromNumericString() instead of the auto-detecting constructor,
and IPBlock::getIterator() passes the GMP position directly.

Fixes rlanvin#74

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

IPBlock not working correctly with prefix larger than 23

1 participant