XGameSave: reject empty container name in XGameSaveDeleteContainer #94

Closed
raylitebull wants to merge 0 commits from upstream-pr/95 into main
raylitebull commented 2026-11-23 11:07:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-23T11:07:24Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5451887199 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/95). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-23T11:07:24Z. --- ## 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.
upstream-sync closed this pull request 2026-11-24 06:57:08 +00:00
raylitebull commented 2026-11-24 07:00:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-23T11:22:04Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7099529125 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/95#issuecomment-7099529125). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-23T11:22:04Z. --- 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()`.
ivall commented 2026-11-24 07:00:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T11:25:40Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7099630005 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/95#issuecomment-7099630005). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T11:25:40Z. --- 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

Sign in to join this conversation.
No reviewers
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
xcl-dev/xcl!94
No description provided.