mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:05:54 +01:00
[PR #147] xgameruntime_gamesave: prevent uint64_t quota underflow in commit() on case-colliding blobs #199
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#199
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/147
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:old-pr/9880📝 Commits (1)
9dca4f3xgameruntime_gamesave: prevent uint64_t quota underflow in commit() on case-colliding blobs📊 Changes
2 files changed (+76 additions, -3 deletions)
View changed files
📝
runtime/shims/xgameruntime_gamesave.cpp(+22 -3)📝
runtime/test/xgameruntime_gamesave_test.cpp(+54 -0)📄 Description
Original description (mentions and
#Nreferences are disabled; the numbers refer to the old repository):Claimed in the coordination issue as: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116740917
(Resubmission of
#8855, which was previously approved by@abnalstlll-byteand verified by@smowlyybefore being closed during the repo transfer cleanup; cleanly rebased ontoProjectLeonida/Leonidamain7e39a81eaand re-verified.)What and why
In
runtime/shims/xgameruntime_gamesave.cpp,commit()computes the post-update quota by iteratingu->opsand subtracting each existing file's size fromuint64_t after = used_bytes(c->user_dir):On Windows NTFS (case-insensitive), if a single
XGameSaveUpdatereferences two blob names that differ only in ASCII case (e.g., deleting or updating"story"and"STORY"when"story"exists on disk), both paths resolve to the same existing file. Subtracting its size twice underflowsuint64_t afterto~UINT64_MAXand causes a tiny update or even a pure delete to fail with a bogusE_GS_QUOTA_EXCEEDED. Likewise, iffs::file_size(p, ec)fails and setsec, it returnsstatic_cast<uintmax_t>(-1), which also wrappedafter.Changes:
commit()(quota calculation loop only):!size_ec && sz != static_cast<uintmax_t>(-1)before subtracting an existing file's size.fs::equivalent(prev, p, eq_ec)is true so each on-disk file is subtracted at most once.after.runtime/test/xgameruntime_gamesave_test.cppfor case-colliding deletes and write + case-colliding delete in a single update.Verification (rebased onto
7e39a81ea)Windows 11 x64, MSVC 19.50 (Visual Studio 18 Community), Windows SDK 10.0.26100.0, Release x64, CPU-only synthetic tests (no game files):
main):xgameruntime_gamesave_testfailed 4 of 66 checks (both case-colliding deletes and write+delete returnedE_GS_QUOTA_EXCEEDED, leaving the blob on disk).7e39a81ea):ctest --test-dir runtime/build -C Release -R ^xgameruntime_gamesave$ --output-on-failure -V: 1/1 passed (xgameruntime_gamesave_test: 66 checks, 0 failures,0.16 sec)python -I scripts/check_no_game_data.py runtime/shims/xgameruntime_gamesave.cpp runtime/test/xgameruntime_gamesave_test.cpp: exit 0git diff origin/main..HEAD --check: exit 0 (LF only, 0 CRLF)AI-assisted: yes
Checklist
docs/design.md, with how it was confirmed. (N/A — offline XGameSave runtime shim fix, not a translator rule.)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.