Formats: guard XMA bitstream reads and sign extension at 0 and >=32 bits #2061
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2061
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2061/head"
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?
@fuzeofficlal on GitHub · 2026-11-25 04:18 UTC · original
fuzeofficlal:fix/formats-xma-bitstream-bounds-907→main· +94 −2 · 1 files · 1 commits · closed without mergingCloses #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.@jeremygold02 on GitHub · 2026-11-25 04:30 UTC · original
Triage verdict — Keep the XMA bit-reader hardening (
fbb6461)Evidence
Checks and limits
Next step
This verification was AI-assisted.
@Marvisak on GitHub · 2026-11-25 09:24 UTC · original
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
@fuzeofficlal on GitHub · 2026-11-25 10:18 UTC · original
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