XGameSave recovery can delete a valid save when v01 and v1 coexist #870

Closed
opened 2026-11-26 04:14:05 +00:00 by github-bot · 4 comments
Owner

@⁠THE-PRO-GAME on GitHub · 2026-11-24 13:00 UTC · original

Save recovery can delete a committed save if its container also contains a leftover directory named v01. The scan parses both v01 and v1 as version 1. When it cleans up what it considers an older version, it reconstructs the name as v1 and deletes the committed save.

I reproduced this on upstream ffe310e using a synthetic save in a temporary directory. The regression test writes a valid v1, creates an empty v01, and reads the save. Before the fix, the read removes v1. After the fix, the original save is still readable and both directories remain.

The patch makes recovery recognize only the canonical version names written by the save system. The commit includes the regression test. Patch and regression test

cargo test --locked -p victory-hle a_noncanonical_directory_does_not_remove_a_committed_save

Related to the broader audit in #810. I used Codex and verified the reproduction with synthetic inputs on Windows 11.

**@⁠THE-PRO-GAME** on GitHub · 2026-11-24 13:00 UTC · [original](https://github.com/Marvisak/VIctory/issues/870) Save recovery can delete a committed save if its container also contains a leftover directory named `v01`. The scan parses both `v01` and `v1` as version 1. When it cleans up what it considers an older version, it reconstructs the name as `v1` and deletes the committed save. I reproduced this on upstream `ffe310e` using a synthetic save in a temporary directory. The regression test writes a valid `v1`, creates an empty `v01`, and reads the save. Before the fix, the read removes `v1`. After the fix, the original save is still readable and both directories remain. The patch makes recovery recognize only the canonical version names written by the save system. The commit includes the regression test. [Patch and regression test](https://github.com/THE-PRO-GAME/VIctory/commit/27491af5b8b2b53f24b4e97f608f80a314113f6b) ```powershell cargo test --locked -p victory-hle a_noncanonical_directory_does_not_remove_a_committed_save ``` Related to the broader audit in #810. I used Codex and verified the reproduction with synthetic inputs on Windows 11.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:14:05 +00:00
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-24 14:15 UTC · original

Independent Windows 11 verification of 27491af (THE-PRO-GAME/VIctory) on Windows 11 x64 (Rust 1.98.1 MSVC):

  • cargo test -p victory-hle a_noncanonical_directory_does_not_remove_a_committed_save: passed
  • cargo test -p victory-hle xgamesave: 9 passed, 0 failed
  • cargo clippy -p victory-hle --all-targets: 0 warnings
  • cargo xtask policy: ok

(Small note for maintainers: commit 27491af itself is stacked on a branch with other commits touching translate.rs/config.rs/texture.rs/cache.rs, so cherry-picking 27491af cleanly isolates the xgamesave.rs fix.)

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-24 14:15 UTC · [original](https://github.com/Marvisak/VIctory/issues/870#issuecomment-7134086023) Independent Windows 11 verification of `27491af` (`THE-PRO-GAME/VIctory`) on Windows 11 x64 (Rust 1.98.1 MSVC): - `cargo test -p victory-hle a_noncanonical_directory_does_not_remove_a_committed_save`: **passed** - `cargo test -p victory-hle xgamesave`: **9 passed, 0 failed** - `cargo clippy -p victory-hle --all-targets`: **0 warnings** - `cargo xtask policy`: ok *(Small note for maintainers: commit `27491af` itself is stacked on a branch with other commits touching `translate.rs`/`config.rs`/`texture.rs`/`cache.rs`, so cherry-picking `27491af` cleanly isolates the `xgamesave.rs` fix.)* AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠wbnm77 on GitHub · 2026-11-24 14:18 UTC · original

Independent native Windows 10 Pro x64 22H2 run on Ryzen 7 5700X with Rust 1.98.1 MSVC. I applied only the synthetic regression test to upstream ffe310eb2098e52169f4c44db5ffdabf43a72622. Running a_noncanonical_directory_does_not_remove_a_committed_save failed with the committed save was removed.

On fork commit 27491af5b8b2b53f24b4e97f608f80a314113f6b, cargo test --offline --locked -p victory-hle --lib modules::xgamesave::tests:: -- --nocapture passed all nine save tests, including the regression. Applying only the canonical-name parser change and the same test to upstream ffe310e also passed all eight save tests in that tree. All saves were generated in temporary directories. Codex (GPT-6) assisted with setup, running the tests and drafting this report.

**@⁠wbnm77** on GitHub · 2026-11-24 14:18 UTC · [original](https://github.com/Marvisak/VIctory/issues/870#issuecomment-7134159132) Independent native Windows 10 Pro x64 22H2 run on Ryzen 7 5700X with Rust 1.98.1 MSVC. I applied only the synthetic regression test to upstream `ffe310eb2098e52169f4c44db5ffdabf43a72622`. Running `a_noncanonical_directory_does_not_remove_a_committed_save` failed with `the committed save was removed`. On fork commit `27491af5b8b2b53f24b4e97f608f80a314113f6b`, `cargo test --offline --locked -p victory-hle --lib modules::xgamesave::tests:: -- --nocapture` passed all nine save tests, including the regression. Applying only the canonical-name parser change and the same test to upstream `ffe310e` also passed all eight save tests in that tree. All saves were generated in temporary directories. Codex (GPT-6) assisted with setup, running the tests and drafting this report.
Author
Owner

@⁠NATON4 on GitHub · 2026-11-24 14:56 UTC · original

Opened #1006 for this: one commit on ffe310e, xgamesave.rs only. Recovery now treats only v<N> exactly as commit writes it (no sign, no leading zeros) as a version; v01/v001/v+1 are neither counted nor removed. Regression test included. Thanks @⁠THE-PRO-GAME for the report and repro.

**@⁠NATON4** on GitHub · 2026-11-24 14:56 UTC · [original](https://github.com/Marvisak/VIctory/issues/870#issuecomment-7135198334) Opened #1006 for this: one commit on `ffe310e`, `xgamesave.rs` only. Recovery now treats only `v<N>` exactly as `commit` writes it (no sign, no leading zeros) as a version; `v01`/`v001`/`v+1` are neither counted nor removed. Regression test included. Thanks @⁠THE-PRO-GAME for the report and repro.
Author
Owner

@⁠winne42 on GitHub · 2026-11-24 20:16 UTC · original

I tested the fixes for this issue as Windows builds under Wine 10.0. Note that all three PRs (#1006, #1035, #1102) were closed by their own authors without being merged, so nothing open currently fixes this.

The name fix works in all three. #1102's code is the same as THE-PRO-GAME's 27491af, which doesn't cherry-pick alone, because it's stacked on 1bd9a93. Each PR's own tests pass, and its new test fails when the name check is reverted. clippy is clean.

A stray folder with a correct name still loses the save, and #870's fix doesn't cover that. I committed a real v1, added a stray entry next to it, then called read():

Stray entry next to v1 main #1006 / #1035 / #1102 + ec2cff0 (THE-PRO-GAME/VIctory#2)
v01, v+1, v001, v02 (empty, or a copy of v1) v1 deleted kept, reads fine kept, reads fine
v2: empty folder, a file, or a corrupt manifest v1 deleted v1 deleted kept, read errors

The empty-v2 case is worse than a failed read. On main and on all three PRs, the next save returns S_OK but commits a fresh v1 holding only the changed blobs. The following read then prunes that v1 too, because v2 still counts as newer. The title is told every save succeeded while nothing survives.

With ec2cff0 the data is kept, but submit returns NO_ACCESS (0x80830002) until the stray folder is removed.

Suggestion: land the name check together with ec2cff0, so recovery never deletes a version before a newer one has been read successfully. A fuller fix would be for current() to use the newest version whose manifest parses, prune only versions below it, and number the next commit above the highest v<N> folder. That way a broken or stray newer folder neither hides the save nor blocks writes.

AI-assisted (Claude Code). Tests were synthetic, using temporary directories, with no game files.

**@⁠winne42** on GitHub · 2026-11-24 20:16 UTC · [original](https://github.com/Marvisak/VIctory/issues/870#issuecomment-7143292421) I tested the fixes for this issue as Windows builds under Wine 10.0. Note that all three PRs (#1006, #1035, #1102) were closed by their own authors without being merged, so nothing open currently fixes this. **The name fix works in all three.** #1102's code is the same as THE-PRO-GAME's `27491af`, which doesn't cherry-pick alone, because it's stacked on `1bd9a93`. Each PR's own tests pass, and its new test fails when the name check is reverted. clippy is clean. **A stray folder with a correct name still loses the save, and #870's fix doesn't cover that.** I committed a real `v1`, added a stray entry next to it, then called `read()`: | Stray entry next to `v1` | `main` | #1006 / #1035 / #1102 | + `ec2cff0` (THE-PRO-GAME/VIctory#2) | |---|---|---|---| | `v01`, `v+1`, `v001`, `v02` (empty, or a copy of `v1`) | `v1` deleted | kept, reads fine | kept, reads fine | | `v2`: empty folder, a file, or a corrupt manifest | `v1` deleted | **`v1` deleted** | kept, read errors | The empty-`v2` case is worse than a failed read. On `main` and on all three PRs, the next save returns `S_OK` but commits a fresh `v1` holding only the changed blobs. The following read then prunes that `v1` too, because `v2` still counts as newer. The title is told every save succeeded while nothing survives. With `ec2cff0` the data is kept, but `submit` returns `NO_ACCESS` (`0x80830002`) until the stray folder is removed. **Suggestion:** land the name check together with `ec2cff0`, so recovery never deletes a version before a newer one has been read successfully. A fuller fix would be for `current()` to use the newest version whose manifest parses, prune only versions below it, and number the next commit above the highest `v<N>` folder. That way a broken or stray newer folder neither hides the save nor blocks writes. _AI-assisted (Claude Code). Tests were synthetic, using temporary directories, with no game files._
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory#870
No description provided.