Shaders: reject a dxbc part inside the header or part table #1942
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1944"
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 imjustprism on 2026-11-25T01:32:53Z.
a part offset that points into the container header or the offset table was accepted: offset 0 came back as a part with the container magic as its fourcc. parts follow the table, so an offset before its end is now refused as malformed. #343 refuses parts that overlap each other, which does not catch this.
the reporter had the same check on a fork and could not open a pull request; this one is written against current main, with a test for the header case and the table case. both fail without the check.
fixes #777
Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T01:35:24Z.
Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head
cba87aeapplied cleanly onto currentmainccfb029.cargo test -p victory-shader --locked: 145 passed, 0 failed, 2 ignored. All tests pass.cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings: 4 errors in test code (unused imports, unused variable, dead fieldrovs), but these are pre-existing on main — they fail identically onccfb029without this PR. The PR introduces no new clippy warnings.Not tested: Windows MSVC build, the title itself. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:05:24Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.145 passed / 0 failed / 2 ignored. DXBC parts inside the header/part table rejected (+1 test) — container-validation hardening against malformed shaders.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:20:29Z.
Automated triage for the maintainers.
Merge candidate.
Container::parseincrates/victory-shader/src/dxbc.rsnow refuses a part whose offset lies before the end of the offset table (HEADER_SIZE + 4 * count). This fixes #777, which is labelled confirmed.On
main, offset 0 is accepted as a part taggedDXBC. The new test covers both the header case and the table case and checks the exact error. It uses the existingbuildhelper. The table itself is already bounds-checked byu32_aton the slice cut to the container's size, so this is the remaining gap from #777.CI:
checkpasses.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T11:16:27Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
afc4f791ontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:02:59Z.
Code review and Windows 11 verification at head
afc4f79123a7merged cleanly ontomain(63bcca43c6a0):crates/victory-shader/src/dxbc.rs:88-95):count <= MAX_PARTS(256) before computingtable_end = HEADER_SIZE + 4 * count(bounded<= 1056, overflow-free), letsu32_atreject truncated tables, and rejects any part withoffset < table_end("part inside the header or table"). Subsequentdata.get(...)bounds checking remains intact.cargo xtask policy:191 files ok;cargo clippy --locked -p victory-shader --tests -- -D warnings: 0 warningsvictory-shader --lib -- dxbc::: 3/3 passed (includingrejects_a_part_inside_the_header_or_the_part_table).LGTM.
[PR #1944] reject a dxbc part inside the header or part tableto [PR #1944] Shaders: reject a dxbc part inside the header or part tableImported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T13:24:51Z.
Review: APPROVED
Reviewed and verified
afc4f79123a7and merged ontoorigin/main(63bcca43; cleangit merge-tree):crates/victory-shader/src/dxbc.rs:86-95is right: withcount <= MAX_PARTS(256),table_end = HEADER_SIZE + 4 * countcannot overflow, and rejectingoffset < table_endprevents parts from aliasing the DXBC header or offset table while keepingcount == 0,offset == table_end, and zero-length part bodies valid. The new regression test covers both header and table offsets. (Existingoffset + 4/offset + 8 + sizearithmetic could move to checked addition in a follow-up if 32-bit overflow-checked builds are targeted.)Local verification:
rustfmt --edition 2024 --check crates/victory-shader/src/dxbc.rs,xtask policy(182 files ok),cargo clippy -p victory-shader --all-targets(defaultand--all-features),dxbc::tests (3 passed), and the merged non-GPUvictory-shaderunit suite (162 passed, 0 failed, 2 ignored) all pass.LGTM.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T23:28:44Z.
Review: APPROVED
LGTM — verified on Windows against
origin/main(63bcca4).cargo test -p victory-shader --lib dxbc:: -- --test-threads=1: all passed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.