Skip to content

fix(primitives): reject underflowing native signed ints - #1139

Merged
DaniPopes merged 2 commits into
alloy-rs:mainfrom
0xalpharush:bug/a5-signed-tryfrom-underflow
Jun 30, 2026
Merged

DaniPopes merged 2 commits into
alloy-rs:mainfrom
0xalpharush:bug/a5-signed-tryfrom-underflow

Conversation

@0xalpharush

@0xalpharush 0xalpharush commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Convert negative native integers through a fallible unsigned resize and signed bounds check.
  • Preserve acceptance of the narrow signed minimum while rejecting values below it.

Regression

  • Extended test_int_conversion, which failed before the fix because I24::try_from(-8_388_609i32) succeeded.

Test Plan

  • cargo test -p alloy-primitives test_int_conversion

@0xalpharush
0xalpharush marked this pull request as ready for review June 30, 2026 18:06
@github-project-automation github-project-automation Bot moved this to Reviewed in Alloy Jun 30, 2026
@DaniPopes
DaniPopes merged commit d153d17 into alloy-rs:main Jun 30, 2026
31 checks passed
@github-project-automation github-project-automation Bot moved this from Reviewed to Done in Alloy Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants