(release/25.1) os: fix undefined behavior in FormatInt64() for INT64_MIN - #3616
Open
metux wants to merge 1 commit into
Open
Conversation
'num *= -1' is undefined behavior when num is INT64_MIN, since the positive value (9223372036854775808) exceeds INT64_MAX. Fix by introducing a uint64_t intermediate and casting to uint64_t before negation, which is well-defined unsigned modular arithmetic and produces the correct absolute value for all int64_t values including INT64_MIN. Fixes: #3610 Reported-by: Alex <alexzk1@users.noreply.github.com> Signed-off-by: Defiant <defiant@x11libre.dev>
Contributor
Author
|
Verdict: APPROVE
This is a minimal, well-targeted fix for undefined behavior in What changed: Why it is correct:
Scope: One line change (master/25.2) or 4-line adaptation (25.1/25.0 where Fixes: #3610 Approved-by: Defiant |
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.
Backport of #3614 (master)