Formats: guard XMA bitstream reads and sign extension at 0 and >=32 bits #2059
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2061"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:18:10Z.
Closes #907.
Summary
Bits::read(n): guardn >= 32by advancing past the highn - 32bits withsaturating_addand returning the low 32 bits viapeek32(), avoiding32 - nunderflow and shift overflow while keeping MSB-first truncation continuous withn < 32.Bits::signed(n): return0without advancing whenn == 0(avoiding<< 32/>> 32shift overflow) andself.read(n) as i32whenn >= 32.Testing
xma::tests::bits_handles_zero_word_and_oversized_widthscovering aligned/unalignedn = 0, 1, 16, 31, 32, 33, 36, 64, u32::MAX, two's-complement extremes, and cursor saturation.cargo test -p victory-formats,cargo clippy --workspace --all-targets -- -D warnings, andcargo xtask policy.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:34:45Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-formats --locked.39 passed / 0 failed. XMA bitstream reads and sign extension guarded at 0 and bounds (+1 test) — XMA decoder hardening; 39 passed / 0 failed / 5 ignored.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:36:25Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-formats --lib xma::— 14 passed, 0 failed (3 ignored), includingbits_handles_zero_word_and_oversized_widthscargo clippy -p victory-formats --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean bounds guards for XMA bitstream reads and sign extension at 0 and >=32 bit widths. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:30:42Z.
Triage verdict — Keep the XMA bit-reader hardening (
fbb6461)Evidence
Checks and limits
Next step
This verification was AI-assisted.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:24:41Z.
Automated triage for the maintainers.
Proposed close.
Bits::readandBits::signed(crates/victory-formats/src/xma.rs) gain branches for widths of 32 bits or more and forsigned(0). Neither case can occur in main. Every caller passes a width bounded below 32:large_value: at most 23frame:channels * channels * 4, andDecoder::newclampschannelsto 1..=2, so at most 16read(len)with a 4-bitlen: at most 15modifier_len: at most 7log2of frame and subframe sizes: smallThe only
signedcall issigned(6). The reviewer above also found no decode path that asks for more than 32 bits. This makes the change a guard for cases that cannot occur. The saturating cursor arithmetic is in the same category, becauseposis bounded by the packet length.This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label. A real caller that can pass such a width, for example from a damaged stream, would change the verdict.
CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T10:18:39Z.
Agreed with the triage analysis — all packet/frame call sites bound
Bits::readwidths below 32 and only passsigned(6)onmain. Closing to keep the review queue focused.Pull request closed