Repository navigation
fix(cmd): reject out-of-range Int() on 32-bit - #4256
Merged
Merged
Conversation
On 386 and arm, Cmd.Int truncated an integer reply that does not fit in an int and returned it with a nil error, while the same number in a bulk string gives Atoi's range error. Return that error for both.
Contributor
Author
|
I used Claude Code to write this change. Per AGENTS.md there's no AI-attribution line in the commit or the PR description, so I'm noting it here. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ndyakov
approved these changes
Nov 2, 2026
ndyakov
left a comment
Member
There was a problem hiding this comment.
looks good to me, thanks @b84330808
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.
On 386 and arm,
Cmd.Int()converts an integer reply with a plainint(...), so a value that doesn't fit wraps silently::2147483648comes back as-2147483648with a nil error, and:9223372036854775807as-1. The same number in a bulk string goes throughstrconv.Atoiand returns a range error.This keeps the fast path when the value fits and otherwise returns exactly what
Atoigives for that number, so integer and bulk-string replies behave the same (like the float32 range check intoFloat32). Nothing changes on 64-bit.TestCmdIntFromIntegerReplyOutOfRangecompares both reply types around the int32 and int64 limits. I added it to thetest-386job's-runlist, since that job only runs selected root tests. It fails withGOARCH=386before the fix and passes after; it passes on amd64 either way (Go 1.27.3).Note
Low Risk
Narrow fix to
Cmd.Int()overflow handling on 32-bit only; no auth, networking, or 64-bit behavior changes.Overview
On 386/arm,
Cmd.Int()no longer silently truncates Redis integer replies (:…) that exceedintrange. It keeps the fast path whenint64(n)round-trips, and otherwise returns the samestrconv.ErrRangebehavior as a bulk-string reply viastrconv.Atoi.Adds
TestCmdIntFromIntegerReplyOutOfRangeto assert integer and bulk replies match around int32/int64 limits, and wires that test into thetest-386CI job’s selective-runlist. 64-bit behavior is unchanged.Reviewed by Cursor Bugbot for commit 15f3834. Bugbot is set up for automated code reviews on this repo. Configure here.