XGameSave: reject empty container name in XGameSaveDeleteContainer #95

Closed
github-bot wants to merge 1 commit from gh-pr/95/head into gh-pr/95/base
Owner

@⁠raylitebull on GitHub · 2026-11-23 11:07 UTC · original
raylitebull:fix/gamesave-empty-container-delete → main · +48 −0 · 1 files · 1 commits · closed without merging

Summary

Fixes a data-loss bug in XGameSaveDeleteContainer / XGameSaveDeleteContainerAsync (crates/xcl/src/hle/xgameruntime/gamesave.rs):

  • Unlike XGameSaveCreateContainer, XGameSaveDeleteContainer did not validate that the container name is non-empty (or within the 256-byte limit).
  • Passing "" caused enc("") == "", so std::fs::remove_dir_all(pr.root.join("")) deleted the entire provider root directory and wiped every save container under it while returning S_OK.
  • XGameSaveDeleteContainer now rejects n.is_empty() || n.len() > 256 with E_GS_INVALID_CONTAINER_NAME, matching XGameSaveCreateContainer.

Testing

  • Added regression test delete_container_rejects_empty_name_without_wiping_provider_root in crates/xcl/src/hle/xgameruntime/gamesave.rs:
    • Before fix (origin/main): XGameSaveDeleteContainer(provider, "") returned S_OK and deleted existing containers and the provider root directory.
    • After fix: Returns E_GS_INVALID_CONTAINER_NAME for both sync XGameSaveDeleteContainer and async XGameSaveDeleteContainerAsync, leaving existing containers and blobs intact.
  • Verified after rebasing onto origin/main (60599a9): cargo build --workspace and cargo test --workspace -- --test-threads=4 pass with 0 failures and 0 new warnings.
**@⁠raylitebull** on GitHub · 2026-11-23 11:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/95) `raylitebull:fix/gamesave-empty-container-delete` → `main` · +48 −0 · 1 files · 1 commits · closed without merging ## Summary Fixes a data-loss bug in `XGameSaveDeleteContainer` / `XGameSaveDeleteContainerAsync` (`crates/xcl/src/hle/xgameruntime/gamesave.rs`): - Unlike `XGameSaveCreateContainer`, `XGameSaveDeleteContainer` did not validate that the container name is non-empty (or within the 256-byte limit). - Passing `""` caused `enc("") == ""`, so `std::fs::remove_dir_all(pr.root.join(""))` deleted the entire provider root directory and wiped every save container under it while returning `S_OK`. - `XGameSaveDeleteContainer` now rejects `n.is_empty() || n.len() > 256` with `E_GS_INVALID_CONTAINER_NAME`, matching `XGameSaveCreateContainer`. ## Testing - Added regression test `delete_container_rejects_empty_name_without_wiping_provider_root` in `crates/xcl/src/hle/xgameruntime/gamesave.rs`: - **Before fix (`origin/main`):** `XGameSaveDeleteContainer(provider, "")` returned `S_OK` and deleted existing containers and the provider root directory. - **After fix:** Returns `E_GS_INVALID_CONTAINER_NAME` for both sync `XGameSaveDeleteContainer` and async `XGameSaveDeleteContainerAsync`, leaving existing containers and blobs intact. - Verified after rebasing onto `origin/main` (`60599a9`): `cargo build --workspace` and `cargo test --workspace -- --test-threads=4` pass with 0 failures and 0 new warnings.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:09:46 +00:00
github-bot closed this pull request 2026-11-26 04:09:46 +00:00
Author
Owner

@⁠raylitebull on GitHub · 2026-11-23 11:22 UTC · original

Closing in favor of #108, which supersedes this fix — it includes the same !name.is_empty() && name.len() <= 256 (E_GS_INVALID_CONTAINER_NAME) validation for both XGameSaveDeleteContainer and XGameSaveDeleteContainerAsync, plus defers async container deletion until work dispatch and serializes deletion with apply().

**@⁠raylitebull** on GitHub · 2026-11-23 11:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/95#issuecomment-7099529125) Closing in favor of #108, which supersedes this fix — it includes the same `!name.is_empty() && name.len() <= 256` (`E_GS_INVALID_CONTAINER_NAME`) validation for both `XGameSaveDeleteContainer` and `XGameSaveDeleteContainerAsync`, plus defers async container deletion until work dispatch and serializes deletion with `apply()`.
Author
Owner

@⁠ivall on GitHub · 2026-11-23 11:25 UTC · original

Merged together with #95–#102 and checked on Windows 11 with an RX 9070: cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; XDefiant (title screen, a scripted A reaches its "Xbox network unavailable" dialog), Unicorn Overlord and Minecraft run. Thanks!

**@⁠ivall** on GitHub · 2026-11-23 11:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/95#issuecomment-7099630005) Merged together with #95–#102 and checked on Windows 11 with an RX 9070: `cargo test --workspace` green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with `XCL_SPLIT_WAVE64=1`; XDefiant (title screen, a scripted A reaches its "Xbox network unavailable" dialog), Unicorn Overlord and Minecraft run. Thanks!

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.