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

Closed
opened 2026-11-24 13:00:52 +00:00 by THE-PRO-GAME · 4 comments
THE-PRO-GAME commented 2026-11-24 13:00:52 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by THE-PRO-GAME on 2026-11-24T13:00:52Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6582356209 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/870). Originally posted by [THE-PRO-GAME](https://github.com/THE-PRO-GAME) on 2026-11-24T13:00:52Z. --- 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.
DenRakEiw commented 2026-11-24 15:03:56 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T14:15:31Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134086023 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/870#issuecomment-7134086023). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T14:15:31Z. --- 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).
wbnm77 commented 2026-11-24 15:03:56 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by wbnm77 on 2026-11-24T14:18:18Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7134159132 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/870#issuecomment-7134159132). Originally posted by [wbnm77](https://github.com/wbnm77) on 2026-11-24T14:18:18Z. --- 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.
NATON4 commented 2026-11-24 15:04:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by NATON4 on 2026-11-24T14:56:29Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135198334 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/870#issuecomment-7135198334). Originally posted by [NATON4](https://github.com/NATON4) on 2026-11-24T14:56:29Z. --- 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.
winne42 commented 2026-11-24 21:03:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by winne42 on 2026-11-24T20:16:40Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143292421 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/870#issuecomment-7143292421). Originally posted by [winne42](https://github.com/winne42) on 2026-11-24T20:16:40Z. --- 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._
Sign in to join this conversation.
No labels
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.

Reference
Marvisak/VIctory#870
No description provided.