Shaders: bounds-check DXIL header offsets and recognize dword zero padding #1303

Open
github-bot wants to merge 1 commit from github-bot/gh-1303 into main AGit
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:17 UTC · original
geiyiliyabumo:test/shader-dxil-audit → main · +98 −19 · 1 files · 1 commits · open

Summary

Audits \crates/victory-shader/src/dxil.rs\ and fixes two parser/layout issues:

  • Replaces unchecked header-relative offset and bitcode length additions with checked slice splits, eliminating overflow risk on 32-bit targets and malformed inputs.
  • Recognizes exact zero padding up to a 4-byte dword boundary as standard PC layout per LLVM's \MCDXContainerWriter, while preserving the raw trailer bytes.
  • Adds 4 deterministic synthetic unit tests covering wire bytes, all four alignment residues, extra trailer data, truncation, and boundary values.

Verification

  • \cargo test -p victory-shader --lib dxil\ ? 7 passed, 0 failed
  • \cargo clippy -p victory-shader --all-targets -- -D warnings\ ? clean
  • \cargo xtask policy\ ? 154 files ok

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1303) `geiyiliyabumo:test/shader-dxil-audit` → `main` · +98 −19 · 1 files · 1 commits · open ## Summary Audits \crates/victory-shader/src/dxil.rs\ and fixes two parser/layout issues: - Replaces unchecked header-relative offset and bitcode length additions with checked slice splits, eliminating overflow risk on 32-bit targets and malformed inputs. - Recognizes exact zero padding up to a 4-byte dword boundary as standard PC layout per LLVM's \MCDXContainerWriter\, while preserving the raw trailer bytes. - Adds 4 deterministic synthetic unit tests covering wire bytes, all four alignment residues, extra trailer data, truncation, and boundary values. ## Verification - \cargo test -p victory-shader --lib dxil\ ? 7 passed, 0 failed - \cargo clippy -p victory-shader --all-targets -- -D warnings\ ? clean - \cargo xtask policy\ ? 154 files ok *AI-assisted; synthetic tests only, no game files.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:26:56 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 02:34 UTC · original

Automated triage for the maintainers. Thank you for the careful tests, but this adds guards for cases that cannot occur. VIctory builds only for x86_64-pc-windows-msvc (rust-toolchain.toml), and on 64-bit usize, 8 + offset + len from two u32 fields cannot overflow; out-of-range values were already rejected by the existing get(..). LLVM's bitstream writer emits whole 32-bit words, so DXIL bitcode never needs the 1-3 bytes of padding that is_standard_layout would now accept. Also, nothing in the workspace calls DxilProgram::parse except its own tests in crates/victory-shader/src/dxil.rs, so behaviour does not change. A malformed input that main handles wrongly, or a caller that needs the change, would change this verdict. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the triage: proposed close label.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 02:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1303#issuecomment-7150893726) <!-- victory-triage v1 head=428725aaed223953709bcc7d526f3070a424587d verdict=proposed-close at=2026-11-25T02:20:29Z --> Automated triage for the maintainers. Thank you for the careful tests, but this adds guards for cases that cannot occur. VIctory builds only for `x86_64-pc-windows-msvc` (`rust-toolchain.toml`), and on 64-bit `usize`, `8 + offset + len` from two `u32` fields cannot overflow; out-of-range values were already rejected by the existing `get(..)`. LLVM's bitstream writer emits whole 32-bit words, so DXIL bitcode never needs the 1-3 bytes of padding that `is_standard_layout` would now accept. Also, nothing in the workspace calls `DxilProgram::parse` except its own tests in `crates/victory-shader/src/dxil.rs`, so behaviour does not change. A malformed input that `main` handles wrongly, or a caller that needs the change, would change this verdict. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the `triage: proposed close` label. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1303/head:github-bot/gh-1303'
git switch 'github-bot/gh-1303'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1303'
git switch 'github-bot/gh-1303'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1303'
git switch 'github-bot/gh-1303'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1303'
git switch 'main'
git merge --squash 'github-bot/gh-1303'
git switch 'main'
git merge --ff-only 'github-bot/gh-1303'
git switch 'main'
git merge 'github-bot/gh-1303'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1303
No description provided.