formats: guard bitstream signed and 32-bit shift overflows in xma #1154
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!1154
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1154/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?
@DaniiL35 on GitHub · 2026-11-24 16:16 UTC · original
fix/xma-bits-shift-overflow→main· +38 −0 · 1 files · 1 commits · closed without mergingResolves #907
Problem
In
crates/victory-formats/src/xma.rs:Bits::signed(n)computedlet sign = 1u32 << (n - 1);without checking ifn == 0(underflow ton - 1 == u32::MAX, causing1u32 << 4294967295overflow panic) orn > 32. Furthermore,val - (1 << n)overflows ifn == 32andvalis non-negative.Bits::read(n)evaluatedlet mask = (1u32 << n) - 1;without checking forn >= 32. Whenn == 32, Rust panics in debug builds on1u32 << 32.Fix
n == 0explicitly inBits::signedreturning0.n >= 32with sign-extension logic (val as i32) and clamp1u64 << nwithout shift overflow.Bits::read, handlen == 0(mask0) andn >= 32(masku32::MAX).bitstream_handles_zero_and_boundary_bit_widthsverifying zero width, 1-bit, 31-bit, 32-bit, and signed conversions.All fixtures are synthetic; zero game data (Rule #1 compliant). Formatted with Rust 2024 edition.
Pull request closed