as_i128 accepts u64 values above i64::MAX - #69
Open
yuxi-liu-wired wants to merge 1 commit into
Open
yuxi-liu-wired wants to merge 1 commit into
yuxi-liu-wired wants to merge 1 commit into
Conversation
The default `ValueAsScalar::as_i128` went through `as_i64`, so every
u64 above `i64::MAX` gave `None`, although each one fits in an i128.
`as_u128` (through `as_u64`) has no such gap, and the `128bit`
implementation on `StaticNode` already handles it.
User-visible through simd-json without the `128bit` feature:
simd_json::serde::from_slice::<i128>(b"9223372036854775808")
before: Err(ExpectedSigned) now: Ok(9223372036854775808)
(serde_json and sonic-rs accept it.)
Test: `node::tests::as_i128_covers_every_integer` (fails before this
change).
Found by a three-way differential fuzzer (serde_json, simd-json,
sonic-rs).
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.
fix: as_i128 accepts u64 values above i64::MAX
The default
ValueAsScalar::as_i128went throughas_i64, so everyu64 above
i64::MAXgaveNone, although each one fits in an i128.as_u128(throughas_u64) has no such gap, and the128bitimplementation on
StaticNodealready handles it.User-visible through simd-json without the
128bitfeature:(serde_json and sonic-rs accept it.)
Test:
node::tests::as_i128_covers_every_integer(fails before thischange).
Testing
Each commit adds a regression test that fails before the change. The full test suite passes and
cargo fmt --checkis clean on the changed files.Found with a differential fuzzer comparing serde_json, simd-json, sonic-rs and jiter.