Validate XGameSave blob count before reading #1123
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!1123
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1123"
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?
@EatCodeSleep2 on GitHub · 2026-11-24 15:57 UTC · original
EatCodeSleep2:fix/xgamesave-read-count→main· +32 −2 · 1 files · 2 commits · openSummary
E_INVALIDARGwhen the required blob-count pointer is null in the synchronous and asynchronous XGameSave read entry points.Testing
cargo test --locked -p victory-hle --lib modules::xgamesave::tests::saves_persist_across_providers -- --exactAI-assisted. Uses synthetic save data only.
@adamdotpy on GitHub · 2026-11-24 16:02 UTC · original
Reviewed on Windows 11 / Rust 1.98.1. The checks are in the right place and for a better reason than "
putwould have caught it":putalready returnsE_INVALIDARGfor a null out-pointer, but only after the write. Inread_blobsthat is afterout.copy_from_nonoverlapping, and inread_resultafter the whole pointer-fixup loop in the title's buffer. So without this, a title passing a null count got its buffer written and thenE_INVALIDARG— half-done work it could not see. Returning before any of it is the fix, andassert!(buffer.iter().all(|&word| word == 0))in both new tests is exactly the property that pins it.read_resultalso returns beforeXAsyncGetResult, so the result stays for a retry, the same contract theBUFFER_TOO_SMALLbranch has. Good; that ordering is the part a later edit could quietly break, so it is worth the sentence in the comment that you already have.Build state on the branch as pushed. Clippy fails, but not on your code:
The branch is one merge behind — its base is
58fed37andxasync.rsthere still hascall((&raw mut block)), which currentmainhas ascall(&raw mut block). Aftergit merge upstream/main(which brings only main's changes),cargo clippy -p victory-hle --all-targets --all-features --locked -- -D warningsis clean andcargo test -p victory-hlegives 94 passed in the lib and 1 in the next target, so your file needs nothing. Mergingmainin clears the red check on the PR.One gap worth closing while you are in this function.
countis now a required input, butnames(blob_names, wanted)returnsNonefor a null names array, andreadtreatsNoneas "every blob in the container" (names.unwrap_or_else(|| version.blobs.clone())). So a title that passesblob_names = nullwithcount = 2gets all of its blobs,countwritten back as the real total, andBUFFER_TOO_SMALLif it sized the buffer for two. Nothing in the branch changes that — it predates this PR — but it is the same class of bug: an argument that says what the title wants, ignored. EitherE_INVALIDARGfor null names withcount > 0, or a// shortcut: a null array means the whole containercomment, and a test says which. There is no test for null names with a non-null count today.Style, non-blocking. This module returns
E_INVALIDARGhere and elsewhere for bad handles;dsp.rsandmedia.rsuseE_POINTERfor "a required out-pointer is null" specifically. Either is defensible, but if the crate wants one rule, this is the pair of functions where it shows.@Zipettte on GitHub · 2026-11-24 18:01 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
4e32dfc:cargo test -p victory-hlepasses, 95 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Marvisak on GitHub · 2026-11-25 01:26 UTC · original
Automated triage for the maintainers.
Proposed close.
This makes
read_blobsandread_resultincrates/victory-hle/src/modules/xgamesave.rsreturnE_INVALIDARGup front when the blob-count pointer is null. Onmainthat call already ends inE_INVALIDARG, throughput(count, ..). The only difference is that the title's buffer is not written first, on a failure path.The count is a required in/out argument of these reads. A title that passes null there would not get its saves on the console either, and nothing in the PR shows the title, or any title, doing so. That makes this a guard for a case that does not occur, and it changes runtime return order with no reference for what the console runtime does. The PR gives no evidence for that behaviour.
What would change this: evidence (from the title's own code or public documentation) that a null count reaches these entry points and what the runtime returns for it. The null-
blob_namesgap raised in the thread would be a separate change, with the same kind of evidence.CI:
checkpasses.This pull request will be closed in 48 hours unless the author pushes a change or a maintainer removes the
triage: proposed closelabel.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.