Repository navigation
BoxedUint: parse "0" as a one-limb zero - #1382
Merged
Merged
Conversation
from_str_radix_vartime() strips leading zeros before decoding, so "0" (likewise "00" or "+0") leaves no digits and produces a BoxedUint with no limbs at all. That value formats as "" rather than "0", and bits_vartime() panics on it with an out-of-bounds index. BoxedUint::zero() has one limb. Return BoxedUint::zero() when no digits are left, and add a test for several spellings of zero in a few radixes. Assisted-by: Claude Code:claude-opus-5-5
wihansaem1991
added a commit
to wihansaem1991/wihansaem1991.github.io
that referenced
this pull request
Nov 1, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1382 +/- ##
==========================================
+ Coverage 91.37% 91.44% +0.06%
==========================================
Files 190 190
Lines 23201 23207 +6
==========================================
+ Hits 21201 21222 +21
+ Misses 2000 1985 -15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tarcieri
reviewed
Nov 2, 2026
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.
BoxedUint::from_str_radix_vartime()strips leading zeros before decoding, so an input that is zero ("0","00","+0") leaves no digits and the result has no limbs at all:This returns
BoxedUint::zero()when no digits are left.from_str_radix_with_precision_vartime()and the byte-slice constructors already produce at least one limb, so only this path changes.The new
from_str_radix_zerotest covers"0","00","+0"and"0_0"in radix 2, 10, 16 and 36; it panics without the change.cargo test --features alloc --lib uint::boxed::encoding(release and debug),cargo clippy --all-targets --all-features -- -D warningsandcargo fmt --all -- --checkpass.This was found by differential fuzzing against
num-bigintand fixed with an AI assistant (Claude Code), which also ran the checks above.🤖 Generated with Claude Code
https://claude.ai/code/session_01Sjtw7YxFWFKBH5rRZfwi9T