Skip to content

Check native integer width before converting key values - #454

Open
Aschenbath wants to merge 1 commit into
go-ini:mainfrom
Aschenbath:fix/oss20more-bc63-ini-native-int-overflow
Open

Aschenbath wants to merge 1 commit into
go-ini:mainfrom
Aschenbath:fix/oss20more-bc63-ini-native-int-overflow

Conversation

@Aschenbath

Copy link
Copy Markdown

Describe the pull request

On a 32-bit target, Key.Int parses 2147483648 successfully as an int64, then converts it to -2147483648. Key.Uint similarly converts 4294967296 to zero. Because no error is returned, MustInt and MustUint also ignore the caller's defaults.

Parse using strconv.IntSize before converting to the native integer type. The regressions cover overflow, fallback defaults and native limits on both word sizes, while checking that explicit 64-bit getters still accept the wider values.

Link to the issue: n/a

Validation on Go 1.26.11, Windows:

  • The regression fails when executed as a 386 test binary on main, and passes with this change.
  • go test -count=1 ./... and go vet ./... pass on amd64.
  • GOARCH=386 CGO_ENABLED=0 go test -count=1 ./... and go vet ./... pass; the 32-bit tests were executed locally.
  • gofmt and git diff --check pass.

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code.

AI usage

OpenAI Codex assisted with investigation, implementation, regression tests, validation, and review of the final diff.

@Aschenbath
Aschenbath requested a review from unknwon as a code owner November 24, 2026 16:06

This branch has not been deployed

No deployments
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.

1 participant