Skip to content

Guard texture and XMA offsets against overflow - #50

Merged
Marvisak merged 2 commits into
Marvisak:mainfrom
Vanthys:fix/format-offset-overflow
Nov 24, 2026
Merged

Marvisak merged 2 commits into
Marvisak:mainfrom
Vanthys:fix/format-offset-overflow

Conversation

@Vanthys

@Vanthys Vanthys commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Use checked arithmetic for texture copy pitches and XMA packet offsets. Add synthetic regression tests for overflowing row and depth pitches, an out-of-range packet index, and a truncated packet header. Make the saved-stream XMA test fail when its fixture directory is empty.

Verified with stable rustc: 20 format tests passed. The three external-fixture tests were skipped in the normal run. A separate run confirmed that the saved-stream test rejects an empty directory.

@DaviTostes

Copy link
Copy Markdown

Tested 4cca767 stacked on #39 on Arch Linux x86_64, rustc 1.98.1: pass.

  • main alone does not build on Linux (E0425 in victory-gpu), so the check uses Build: make workspace tests run on Linux #39 as the base; the merge is clean.
  • cargo test --workspace: 156 passed, 0 failed, 3 ignored.
  • The three new tests run and pass: texture_copies_reject_overflowing_pitches, volume_copy_rejects_overflowing_depth_pitch and packet_rejects_out_of_range_indices_and_partial_headers. No game data used.

AI-assisted (DeepSeek V4.1 Flash coding agent).

@lordon1a

Copy link
Copy Markdown
Contributor

Verified 4cca76795 on Windows 11 (x86_64-pc-windows-gnullvm, rustc 1.100.0, applied cleanly to main@35b054ec0): pass.

  • cargo xtask policy: 150 files ok
  • cargo test -p victory-formats: 20 passed, 0 failed, 3 ignored (+3 new overflow guard tests in texture.rs / xma.rs).

AI-assisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants