Validate XGameSave blob count before reading #1123
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by EatCodeSleep2 on 2026-11-24T15:57:22Z.
Summary
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.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T16:01:25Z.
Review: APPROVED
Tested merged cleanly onto
main(ffe310e) on Windows 11 x64 (Rust 1.98.1 MSVC):cargo test -p victory-hle: 94 passed, 0 failed (plusno_dll_planting: 1 passed)cargo clippy -p victory-hle --all-targets: 0 warningscargo xtask policy: okClean validation of
XGameSaveblob counts before reading. Approving.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T16:02:14Z.
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.Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T18:01:40Z.
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).
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T18:50:34Z.
Review: APPROVED
Tested
4e32dfcon Windows 11, RTX 5070, MSVC: builds,cargo test --workspace --no-fail-fast602 passed, 0 failed (on our fork main).saves_persist_across_providerspasses with the new invalid calls.countOfBlobsis a required in/out pointer for bothXGameSaveReadBlobDataandXGameSaveReadBlobDataResult, soE_INVALIDARGfor null matches the GDK.read_resultthe check comes beforeXAsyncGetResult, so the result isn't consumed and a retry with a valid pointer succeeds, which the test checks along with the untouched buffer.read_blobs, refusing null instead of treating it as 0 changes behaviour only for an invalid call. That's fine.Merged into our fork's main.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:26:18Z.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.