Formats XMA: reject truncated quant_step escape sequences #3124
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by Arkenoz on 2026-11-26T09:15:52Z.
Summary
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
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T10:03:18Z.
Review: APPROVED
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.Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T11:24:13Z.
NVIDIA full-suite run, to go with the reports above by fuzeofficlal, since none of them names a GPU run. Tested exact head
ca16b87(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 869 passed, 0 failed, 10 ignored.truncated_negative_quant_step_escape_returns_error,truncated_positive_quant_step_escape_after_31_returns_error,quant_step_escape_reads_exact_five_remaining_bits.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.