[PR #1141] [CLOSED] OLD-9880: XGameSave commit() counts a case-aliased blob once, so the quota cannot underflow (carries #147) #1175

Closed
opened 2026-11-26 20:20:21 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1141
Author: @TimIdle
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: oldpr-9880-gamesave-quota


📝 Commits (2)

  • 2ad0bd5 xgameruntime_gamesave: prevent uint64_t quota underflow in commit() on case-colliding blobs
  • 0b23aa4 xgameruntime_gamesave: a blob name differing only in case is the same blob

📊 Changes

2 files changed (+100 additions, -6 deletions)

View changed files

📝 runtime/shims/xgameruntime_gamesave.cpp (+38 -6)
📝 runtime/test/xgameruntime_gamesave_test.cpp (+62 -0)

📄 Description

Claimed in the coordination issue as: OLD-9880 (claim)

What and why

This carries forward old-pr/9880 by @ChalanaGimhanaX (draft #147). Their commit is cherry-picked onto main with the author kept, and rebased over #992. A second commit by me covers what #992 changed.

encode_name keeps ASCII letters as they are, so the blobs story and STORY are the same file on NTFS. commit() subtracted the existing file's size once per name. An update that names that file twice subtracted it twice, the uint64_t total wrapped, and a small delete failed with E_GS_QUOTA_EXCEEDED.

The fix subtracts each on-disk file once (fs::equivalent), clamps the subtraction at 0 and saturates the addition.

#992 then gave commit() a rollback path. With both names in one update, the second name's backup fails after the first was applied, and the update returns E_GS_OUT_OF_LOCAL_STORAGE. So the second commit makes XGameSaveSubmitBlobWrite and XGameSaveSubmitBlobDelete refuse a name that differs from one already in the update only in case, with E_INVALIDARG, as they already refuse an exact duplicate. The case-alias checks now expect that refusal. They compare the remaining quota with its value before the seed, because the rollback checks of #992 leave their container behind.

Tested

Native Windows 11 10.0.26300 (NTFS), MSVC 19.44, RelWithDebInfo, on main 364ab4e plus the two commits.

Check Result
xgameruntime_gamesave_test with both commits 88 checks, 0 failures
xgameruntime_gamesave_test with main's xgameruntime_gamesave.cpp 88 checks, 7 failures, starting with FAIL a delete of "STORY" after one of "story" in the same update is refused as the same blob
xgameruntime_gamesave_test with only the first commit's xgameruntime_gamesave.cpp 88 checks, 7 failures (the same 7)
full ctest -j 6 316 of 316 passed, gameinput disabled.

Not covered: a name is still kept in the case it was first written in. Whether names should be case-folded on disk is a separate question.

GPUs tested: n/a (no GPU code)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator rule here.)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1141 **Author:** [@TimIdle](https://github.com/TimIdle) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `oldpr-9880-gamesave-quota` --- ### 📝 Commits (2) - [`2ad0bd5`](https://github.com/ubiquitarianism/leonida/commit/2ad0bd52d3d601df0d338b7a26ec42d15de74696) xgameruntime_gamesave: prevent uint64_t quota underflow in commit() on case-colliding blobs - [`0b23aa4`](https://github.com/ubiquitarianism/leonida/commit/0b23aa4863413251c70aa17f2fc322f9cb2d7307) xgameruntime_gamesave: a blob name differing only in case is the same blob ### 📊 Changes **2 files changed** (+100 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/xgameruntime_gamesave.cpp` (+38 -6) 📝 `runtime/test/xgameruntime_gamesave_test.cpp` (+62 -0) </details> ### 📄 Description Claimed in the coordination issue as: OLD-9880 ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7141481946)) ### What and why This carries forward `old-pr/9880` by @ChalanaGimhanaX (draft #147). Their commit is cherry-picked onto `main` with the author kept, and rebased over #992. A second commit by me covers what #992 changed. `encode_name` keeps ASCII letters as they are, so the blobs `story` and `STORY` are the same file on NTFS. `commit()` subtracted the existing file's size once per name. An update that names that file twice subtracted it twice, the `uint64_t` total wrapped, and a small delete failed with `E_GS_QUOTA_EXCEEDED`. The fix subtracts each on-disk file once (`fs::equivalent`), clamps the subtraction at 0 and saturates the addition. #992 then gave `commit()` a rollback path. With both names in one update, the second name's backup fails after the first was applied, and the update returns `E_GS_OUT_OF_LOCAL_STORAGE`. So the second commit makes `XGameSaveSubmitBlobWrite` and `XGameSaveSubmitBlobDelete` refuse a name that differs from one already in the update only in case, with `E_INVALIDARG`, as they already refuse an exact duplicate. The case-alias checks now expect that refusal. They compare the remaining quota with its value before the seed, because the rollback checks of #992 leave their container behind. ### Tested Native Windows 11 10.0.26300 (NTFS), MSVC 19.44, RelWithDebInfo, on `main` `364ab4e` plus the two commits. | Check | Result | |---|---| | `xgameruntime_gamesave_test` with both commits | 88 checks, 0 failures | | `xgameruntime_gamesave_test` with `main`'s `xgameruntime_gamesave.cpp` | 88 checks, 7 failures, starting with `FAIL a delete of "STORY" after one of "story" in the same update is refused as the same blob` | | `xgameruntime_gamesave_test` with only the first commit's `xgameruntime_gamesave.cpp` | 88 checks, 7 failures (the same 7) | | full `ctest -j 6` | 316 of 316 passed, `gameinput` disabled. | Not covered: a name is still kept in the case it was first written in. Whether names should be case-folded on disk is a separate question. GPUs tested: n/a (no GPU code) AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator rule here.) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:20:21 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#1175
No description provided.