Repository navigation
fix(id/tuple): decode range-checks negative ints, rejects NaN and non-minimal ints (#1610) - #1746
Conversation
…-minimal ints (#1610) decode_one admitted encodings the encoder can never produce: negative magnitudes of 0 (decoded to Int(0)) or above 2^63 (wrapped to zero/positive), FLOAT64 payloads reversing to NaN, and non-minimal int spellings with redundant leading bytes. Add the mirror range check (1..=2^63, so i64::MIN stays legal), a NaN refusal after the sort transform, and reject non-minimal ints in both sign branches. No encoder change; tests cover each refusal plus the i64::MIN boundary and infinity staying decodable.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 39 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Fixes #1610 (per triage task 1711, verdict CONFIRMED; implementation queue task 1851).
decode_oneinpkgs/id/src/tuple.rsadmitted three classes of encodings the encoder can never produce:Int(0), and a magnitude above 2^63 wrapped through0u64.wrapping_sub(abs)to a zero or positive value (u64::MAX →Int(1)).float()refuses NaN, but a crafted payload reversing to NaN decoded happily.Change (decode only — the encoder and all on-disk/document encodings are byte-identical):
1..=2^63;2^63itself stays legal — it isi64::MIN, with a boundary test (crafted payload + encoder round-trip).ZEROtag), and a negative payload's first byte must not be0xFF(magnitude's top byte non-zero). Documented in branch comments.Tests: new unit tests for each refusal, the
i64::MINboundary, and infinity. Existing tuple tests unchanged. Verification: CI on this PR (cargo test for the id crate).Need help on this PR? Tag
@codesmith-botwith what you need.