Formats: XMA bit reads of 0 or more than 32 bits do not overflow a shift #992

Closed
github-bot wants to merge 1 commit from gh-pr/992/head into gh-pr/992/base
Owner

@⁠NATON4 on GitHub · 2026-11-24 14:44 UTC · original
formats/xma-bit-widths → main · +46 −1 · 1 files · 1 commits · closed without merging

Bits::signed(0) shifted by 32 (a panic in debug builds) and Bits::signed(n) / Bits::read(n) for n > 32 underflowed 32 - n. Zero bits now read as 0; past 32 bits the low 32 are the value and all n bits are consumed, for both. Widths 1 to 32 read as before.

No caller reaches these widths today (the decoder clamps to two channels, so the widest read is 16 bits and signed is only called with 6); this keeps a later caller or a damaged stream from panicking the decoder. The new test panics on the old code and passes now.

Closes #907.

**@⁠NATON4** on GitHub · 2026-11-24 14:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/992) `formats/xma-bit-widths` → `main` · +46 −1 · 1 files · 1 commits · closed without merging `Bits::signed(0)` shifted by 32 (a panic in debug builds) and `Bits::signed(n)` / `Bits::read(n)` for n > 32 underflowed `32 - n`. Zero bits now read as 0; past 32 bits the low 32 are the value and all n bits are consumed, for both. Widths 1 to 32 read as before. No caller reaches these widths today (the decoder clamps to two channels, so the widest read is 16 bits and `signed` is only called with 6); this keeps a later caller or a damaged stream from panicking the decoder. The new test panics on the old code and passes now. Closes #907.
`Bits::signed(0)` shifted by 32 (a panic in debug builds) and
`Bits::signed(n)` / `Bits::read(n)` for n > 32 underflowed `32 - n`.
Zero bits now read as 0; past 32 bits the low 32 are the value and all
n bits are consumed, for both. Widths 1 to 32 read as before.

No caller reaches these widths today (the decoder clamps to two channels,
so the widest read is 16 bits and `signed` is only called with 6); this
keeps a later caller or a damaged stream from panicking the decoder.
The new test panics on the old code and passes now.

Closes #907.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:16:18 +00:00
github-bot closed this pull request 2026-11-26 04:16:18 +00:00
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 15:13 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 87f7cb8: cargo test -p victory-formats passes, 24 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 15:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/992#issuecomment-7135650265) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 87f7cb8: `cargo test -p victory-formats` passes, 24 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!992
No description provided.