Skip to content

XGameSave: reject empty container name in XGameSaveDeleteContainer - #95

Closed
raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:fix/gamesave-empty-container-delete
Closed

raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:fix/gamesave-empty-container-delete

Conversation

@raylitebull

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member Author

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

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants