Skip to content

inspect: Fix an extreme overflow case in natural_sort#3487

Merged
smalis-msft merged 1 commit into
microsoft:mainfrom
smalis-msft:nat-sort-overflow
May 14, 2026
Merged

inspect: Fix an extreme overflow case in natural_sort#3487
smalis-msft merged 1 commit into
microsoft:mainfrom
smalis-msft:nat-sort-overflow

Conversation

@smalis-msft
Copy link
Copy Markdown
Contributor

Found by fuzzers.

@smalis-msft smalis-msft requested a review from a team as a code owner May 14, 2026 15:00
Copilot AI review requested due to automatic review settings May 14, 2026 15:00
@smalis-msft smalis-msft enabled auto-merge (squash) May 14, 2026 15:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a panic in natural_sort::parse_prefix where n * base + digit could overflow u64 even when n * base did not, by combining the multiply and add via checked_add.

Changes:

  • Replace n.checked_mul(...) followed by unchecked + d with chained checked_mul().and_then(checked_add).
  • Add a regression test exercising a decimal value that triggers the previously-panicking overflow path.

@smalis-msft smalis-msft merged commit ea2772b into microsoft:main May 14, 2026
99 of 102 checks passed
@smalis-msft smalis-msft deleted the nat-sort-overflow branch May 14, 2026 17:25
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.

3 participants