Formats XMA: reject truncated quant_step escape sequences #3126
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!3126
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3126"
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?
@Arkenoz on GitHub · 2026-11-26 09:15 UTC · original
Arkenoz:fix/xma-quant-step-escape→main· +119 −6 · 1 files · 1 commits · openSummary
Fixes truncated
quant_stepescape-code handling inDecoder::subframe(crates/victory-formats/src/xma.rs):while b.pos + 5 < b.endloop exited silently without signalling an error when the bitstream ended before a terminal 5-bit value (!= 31), allowing truncated subframes (e.g. second subframe withreuse_sf) to decode and returnOk(()).quant_stepaccumulation: after a premature loop exit,quant_step += if negative { -(quant + step) } else { quant + step }reused the stalestepvalue — adding+32whenstep == -32with 0 iterations (cancelling the initial-32), or double-counting the final31after one or more31escape codes.<vs<=):b.pos + 5 < b.endprevented reading a valid 5-bit escape when exactly 5 bits remained.The escape loop now reads 5 bits via
b.read(5), returnsErr(Error("quant step"))onb.overread(), and accumulatesquant += escdirectly before breaking onesc != 31.Testing
crates/victory-formats/src/xma.rs(all verified failing before the fix and passing after):truncated_negative_quant_step_escape_returns_errortruncated_positive_quant_step_escape_after_31_returns_errorquant_step_escape_reads_exact_five_remaining_bitsrustfmt --edition 2024 --check crates/victory-formats/src/xma.rs— 0 diffs on modified/added linescargo clippy --workspace --all-targets -- -D warnings— passedcargo check --workspace --all-targets— passedcargo xtask policy— passed (asset policy: 191 files ok)cargo test -p victory-formats --locked— passed (49 passed; 0 failed; 5 ignored)Coordination & AI disclosure
@fuzeofficlal on GitHub · 2026-11-26 10:03 UTC · original · approved these changes
Clean fix for all three issues in the
quant_stepescape loop (xma.rs:1036-1054): checkingb.overread()(pos > end) immediately afterb.read(5)rejects truncated escape sequences withError("quant step"), accepts a complete 5-bit terminal code when exactly 5 bits remain, and removes the stalestepreuse after loop exit. The two-subframe fixture tests (truncated_negative_quant_step_escape_returns_error,truncated_positive_quant_step_escape_after_31_returns_error,quant_step_escape_reads_exact_five_remaining_bits) exercise thereuse_sfpath that previously masked truncation.Verified locally on Windows 11 x64 (
ca16b871):cargo run --locked -p xtask -- policy: passed (191 files ok)cargo clippy -p victory-formats --all-targets --locked -- -D warnings(default and--all-features): cleancargo test -p victory-formats --locked: 49 passed, 0 failed, 5 ignoredrustfmt --edition 2024 --check crates/victory-formats/src/xma.rs: 0 diffs in the modified/added hunks (remaining diffs are pre-existing elsewhere in the file)Optional: adding a valid decode case with repeated
31escapes followed by a terminal code would also pin down multi-escape accumulation and field alignment end-to-end.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.