Audio, watch: no overflow on huge title sizes (XMA read advance, fread) #88
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!88
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/88/head"
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?
@AndyLatimer on GitHub · 2026-11-24 00:22 UTC · original
AndyLatimer:fix/title-size-overflows→main· +22 −3 · 2 files · 2 commits · merged 2026-11-24 08:47 UTCTwo places added a size the title passes to another value in unchecked integer arithmetic. In debug builds that panics on overflow; in release it wraps.
XMA read advance (
crates/victory-hle/src/modules/audio.rs,advance_read):ADVANCE_XMA_READcomputed(read block + blocks) % sizeinu32.blocksis the title's count, passed through unchecked, and the read block is a 5-bit field. A count nearu32::MAX(for example a wrapped difference of block numbers) overflowed. The count is now reduced modulo the ring size first:(read + blocks % size) % size. For every count that did not overflow, the result is the same.Announced writes (
crates/victory-gpu/src/watch.rs,writing/kernel_will_writeandtitle_memory_remapped):freadpassessize.saturating_mul(count)as the length, butwritingthen computedat + lenunchecked.fread(buf, 1, SIZE_MAX, f)overflowed.title_memory_remappedhad the same sum. Both ends now saturate at the top of the address space, so the range covers up to the end (the guarded blocks in it are opened, as for any write).Testing
cargo test --workspace: 225 passed, 3 ignored (need external files).watch::ranges_past_the_address_space_end_do_not_overflow. It uses a range at the top of the address space, where no other test guards memory.xma_contexts_decode_into_their_output_ringsnow advances read block 3 byu32::MAXon a ring of four and expects block 2.cargo clippy --workspace --all-targets: 0 warnings.cargo xtask policy: pass (148 files).rustfmt --checkreports no differences in the changed lines. The other diffs in these files already exist onmain.🤖 Generated with Claude Code
@DaviTostes on GitHub · 2026-11-24 01:13 UTC · original
Tested
ec0d155: pass, no regression.d3dcompiler_47for the shader compiler.: 36 passed, 1 failed.resource::tests::buffer_data_reaches_the_host_texture, i.e. #128, not this PR. The new watch test passes.No game data used.