Game: validate DXBC containers in SGD5 records #425

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

@⁠enzoduarte1 on GitHub · 2026-11-24 03:14 UTC · original
enzoduarte1:game/sgd5-dxbc-container → main · +91 −0 · 1 files · 1 commits · open

What

Record::unpack() in the SGD5 reader only checks that the deflate stream inflates to the declared length. A record can hold arbitrary bytes, so callers that need a shader container each have to repeat the DXBC header checks (or skip the record later, after counting it).

This adds two accessors to victory-game::sgd5::Record:

  • container(): unpacks and returns the bytes only when they have a DXBC header whose total size and part-offset table fit inside the data;
  • digest(): the 16-byte container digest from that header, for identifying a shader without unpacking again.

Both return None for corrupt streams, non-DXBC payloads and malformed headers. unpack() keeps its existing behavior. Tests use synthetic buffers only: a valid two-part container, a non-shader payload, bad magic, out-of-range total size, part count overflow and a truncated header. No title data is involved.

Tested

  • Windows 11, Rust 1.98.1, x86_64-pc-windows-gnu (no MSVC linker on this machine).
  • cargo test -p victory-game: 4 passed.
  • cargo test --workspace --exclude victory-loader -- --test-threads=1: all suites passed.
  • cargo clippy -p victory-game --all-targets -- -D warnings: clean.
  • rustfmt --edition 2024 --check crates/victory-game/src/sgd5.rs and git diff --check: clean.
  • cargo xtask policy: 151 files ok. No game files or data taken from them were added.
  • Not tested: cargo test -p victory-loader --test load_probe. Its fixture passes MSVC's /DELAYLOAD flag, which MinGW rejects here; the same failure occurs on unmodified main.

Checklist

  • cargo fmt, cargo clippy --workspace --all-targets and cargo test --workspace pass — see the toolchain limitations above; the changed crate is clean.
  • cargo xtask policy passes. The change adds no game files or data taken from them (docs/asset-policy.md).
  • If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and tests; I reviewed and ran them.
**@⁠enzoduarte1** on GitHub · 2026-11-24 03:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/425) `enzoduarte1:game/sgd5-dxbc-container` → `main` · +91 −0 · 1 files · 1 commits · open ## What `Record::unpack()` in the SGD5 reader only checks that the deflate stream inflates to the declared length. A record can hold arbitrary bytes, so callers that need a shader container each have to repeat the DXBC header checks (or skip the record later, after counting it). This adds two accessors to `victory-game::sgd5::Record`: - `container()`: unpacks and returns the bytes only when they have a DXBC header whose total size and part-offset table fit inside the data; - `digest()`: the 16-byte container digest from that header, for identifying a shader without unpacking again. Both return `None` for corrupt streams, non-DXBC payloads and malformed headers. `unpack()` keeps its existing behavior. Tests use synthetic buffers only: a valid two-part container, a non-shader payload, bad magic, out-of-range total size, part count overflow and a truncated header. No title data is involved. ## Tested - Windows 11, Rust 1.98.1, `x86_64-pc-windows-gnu` (no MSVC linker on this machine). - `cargo test -p victory-game`: 4 passed. - `cargo test --workspace --exclude victory-loader -- --test-threads=1`: all suites passed. - `cargo clippy -p victory-game --all-targets -- -D warnings`: clean. - `rustfmt --edition 2024 --check crates/victory-game/src/sgd5.rs` and `git diff --check`: clean. - `cargo xtask policy`: 151 files ok. No game files or data taken from them were added. - Not tested: `cargo test -p victory-loader --test load_probe`. Its fixture passes MSVC's `/DELAYLOAD` flag, which MinGW rejects here; the same failure occurs on unmodified `main`. ## Checklist - [ ] `cargo fmt`, `cargo clippy --workspace --all-targets` and `cargo test --workspace` pass — see the toolchain limitations above; the changed crate is clean. - [x] `cargo xtask policy` passes. The change adds no game files or data taken from them (`docs/asset-policy.md`). - [x] If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and tests; I reviewed and ran them.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:03:26 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 03:38 UTC · original

Verified 012ce71 on Arch Linux x86_64 (rustc 1.98.1, cargo test -p victory-game): 4 passed, 0 failed, 0 ignored.

Not covered: SGD5 streams from the title's archives (no game data here).

**@⁠DaviTostes** on GitHub · 2026-11-24 03:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/425#issuecomment-7121289343) Verified `012ce71` on **Arch Linux x86_64** (rustc 1.98.1, `cargo test -p victory-game`): **4 passed, 0 failed, 0 ignored**. Not covered: SGD5 streams from the title's archives (no game data here).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:17 UTC · original

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-game/src/sgd5.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/425#issuecomment-7148348134) <!-- victory-triage v1 head=012ce71c5a8ce7ed19c9d443a691136924e6ebdc verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `crates/victory-game/src/sgd5.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request has changes conflicting with the target branch.
  • crates/victory-game/src/sgd5.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-425'
git switch 'github-bot/gh-425'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-425'
git switch 'github-bot/gh-425'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-425'
git switch 'main'
git merge --squash 'github-bot/gh-425'
git switch 'main'
git merge --ff-only 'github-bot/gh-425'
git switch 'main'
git merge 'github-bot/gh-425'
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!425
No description provided.