Shaders: reject overlapping DXBC container parts #343
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!343
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-343"
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?
@pedrofort on GitHub · 2026-11-24 02:25 UTC · original
<head></head>pedrofort:fix-dxbc-overlap→main· +52 −0 · 1 files · 1 commits · openProblem
Container::parse()validates individual DXBC part boundaries but does not check whether multiple parts overlap.As a result, malformed containers with duplicate part offsets or nested parts are accepted.
Fix
Collect and sort the byte ranges of parsed parts.
Reject intersecting ranges with
ShaderError::Malformed.Preserve the original part order.
Allow valid adjacent parts, including empty payloads.
This complements #326, which addresses parts overlapping the container header rather than each other.
Verification
Apple M5, macOS arm64, Rust 1.98.1, base commit
Test | Before | After -- | -- | -- Duplicate offsets | FAIL | PASS Nested part | FAIL | PASS Adjacent empty parts | PASS | PASS Complete shader unit test suite | — | 59/59 PASSd2a4bae.Clippy (
--lib -- -D warnings): clean.The existing non-Windows
constant_colordead-code warning is unchanged.All test containers are synthetic. No game data was used.
AI-assisted implementation and test preparation (ChatGPT), with tests executed locally on Apple Silicon.
@jeremygold02 on GitHub · 2026-11-24 04:22 UTC · original
Tested PR #343 at head
9459c12d2e3a3d48ac2e073e7d3d9a888bfa913d(state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at9459c12d2e3a3d48ac2e073e7d3d9a888bfa913d.cargo test --locked -p victory-shader overlap_— passed (ok. 3 passed; 0 failed; 0 ignored; 0 measured; 69 filtered out; finished in 0.00s ); cases: dxbc::tests::overlap_rejects_duplicate_offsets, dxbc::tests::overlap_accepts_adjacent_empty_parts, dxbc::tests::overlap_rejects_nested_part.Behavior covered: Checks duplicate and nested DXBC part offsets are rejected while adjacent empty parts remain accepted.
Code: crates/victory-shader/src/dxbc.rs
@sebastianspicker on GitHub · 2026-11-24 11:02 UTC · original
I think #326 covers this. I copied the three tests from this PR unchanged into #326 at
bf594d5, and all three pass there. Onmain(ffe310e),overlap_rejects_duplicate_offsetsandoverlap_rejects_nested_partfail as expected, andoverlap_accepts_adjacent_empty_partspasses. #326 also checks a part reaching into an earlier one and parts inside the header, so it's the wider version of the same fix.If the maintainer prefers this one because it's smaller, the sort-then-
windows(2)check looks right to me; adjacent and empty parts stay valid. Otherwise this could close once #326 merges.AI-assisted.
@Marvisak on GitHub · 2026-11-25 00:28 UTC · original
Automated triage for the maintainers.
Needs work. The overlap check in
Container::parse(crates/victory-shader/src/dxbc.rs) is correct (sorted ranges,windows(2), touching and empty parts allowed); note the slice reads were already bounds-checked, so overlaps were never a memory-safety issue.Container::parsealso reads the title's own shader containers, so a new rejection makes affected programs fail to translate, and this was tested only on synthetic containers. Please run translation over the title's shaders (e.g.victory translate --list) and report that no program that translated before is now refused; that would make it mergeable. #326 also contains an overlap check inside a large bundle; this smaller PR could be the one to take.CI: no check runs on the head commit.
Generated by Claude Code
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.