[PR #2359] [MERGED] xgamesave: a blob read accepts the unpadded buffer size (RT-XGAMESAVE-UNPADDED-READ) #2363

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2359
Author: @DadaCap
Created: 11/26/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: xgamesave-unpadded-read


📝 Commits (1)

  • be829a4 xgameruntime_gamesave: accept an XGameSaveReadBlobData buffer of the unpadded size

📊 Changes

2 files changed (+30 additions, -9 deletions)

View changed files

📝 runtime/shims/xgameruntime_gamesave.cpp (+16 -9)
📝 runtime/test/xgameruntime_gamesave_test.cpp (+14 -0)

📄 Description

Claimed in the coordination issue as: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7196167761

Depends on: none. It merges cleanly with current main, #2003 and #1952 (both also touch the game-save files). It conflicts with draft #147, which already conflicts with main on its own.

What and why

XGameSaveReadBlobData (and the result of XGameSaveReadBlobDataAsync) packs the XGameSaveBlob array, then each blob's data and name into the title's buffer. A title sizes that buffer as the plain sum of sizeof(XGameSaveBlob), the data, and the name with its NUL for each blob. The shim required its own 8-byte aligned layout, which is larger, so it refused such a buffer with E_GS_PROVIDED_BUFFER_TOO_SMALL. The retail title took that refusal as a failed save and showed its autosave error.

The fix, in runtime/shims/xgameruntime_gamesave.cpp:

  • packed_size(blobs, aligned): the minimum the read requires, and the size the async read reports, is now the unpadded sum.
  • pack(blobs, buffer, buffer_size) keeps the 8-byte aligned layout when the buffer has room for it, and packs the blobs back to back otherwise. Callers that already passed a larger buffer get the same layout as before.

Tested

  • xgameruntime_gamesave_test gains two checks (made-up blobs, no game data): a read into a buffer of exactly the unpadded size succeeds and returns the blob byte for byte inside the buffer, and one byte less returns E_GS_PROVIDED_BUFFER_TOO_SMALL.
  • Before/after: with main's shim the new test fails (78 checks, 1 failures: the exact-size read is refused); with the change all checks pass (ctest -R ^xgameruntime_gamesave).
  • Built gta6rt (Windows 11, MSVC, Ninja, RelWithDebInfo). Not run: the full ctest suite and the translator suite (no shader or translator code changes).
  • python -I scripts/check_no_game_data.py on the changed files: clean.
  • Game observation, on a local build of main plus other local work: in the retail game on an RTX 5080 the read that failed now succeeds and the autosave error dialog no longer appears. No log lines or captures are quoted here.

GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 (game observation only; the test needs no GPU).

AI-assisted: yes (Claude Code, Opus 5.5)

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. (n/a: no translator rule)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr


🔄 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/2359 **Author:** [@DadaCap](https://github.com/DadaCap) **Created:** 11/26/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `xgamesave-unpadded-read` --- ### 📝 Commits (1) - [`be829a4`](https://github.com/ubiquitarianism/leonida/commit/be829a4d649b011c9e3c31f017923b0a0af21d86) xgameruntime_gamesave: accept an XGameSaveReadBlobData buffer of the unpadded size ### 📊 Changes **2 files changed** (+30 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/xgameruntime_gamesave.cpp` (+16 -9) 📝 `runtime/test/xgameruntime_gamesave_test.cpp` (+14 -0) </details> ### 📄 Description Claimed in the coordination issue as: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7196167761 Depends on: none. It merges cleanly with current `main`, #2003 and #1952 (both also touch the game-save files). It conflicts with draft #147, which already conflicts with `main` on its own. ### What and why `XGameSaveReadBlobData` (and the result of `XGameSaveReadBlobDataAsync`) packs the `XGameSaveBlob` array, then each blob's data and name into the title's buffer. A title sizes that buffer as the plain sum of `sizeof(XGameSaveBlob)`, the data, and the name with its NUL for each blob. The shim required its own 8-byte aligned layout, which is larger, so it refused such a buffer with `E_GS_PROVIDED_BUFFER_TOO_SMALL`. The retail title took that refusal as a failed save and showed its autosave error. The fix, in `runtime/shims/xgameruntime_gamesave.cpp`: - `packed_size(blobs, aligned)`: the minimum the read requires, and the size the async read reports, is now the unpadded sum. - `pack(blobs, buffer, buffer_size)` keeps the 8-byte aligned layout when the buffer has room for it, and packs the blobs back to back otherwise. Callers that already passed a larger buffer get the same layout as before. ### Tested - `xgameruntime_gamesave_test` gains two checks (made-up blobs, no game data): a read into a buffer of exactly the unpadded size succeeds and returns the blob byte for byte inside the buffer, and one byte less returns `E_GS_PROVIDED_BUFFER_TOO_SMALL`. - Before/after: with `main`'s shim the new test fails (`78 checks, 1 failures`: the exact-size read is refused); with the change all checks pass (`ctest -R ^xgameruntime_gamesave`). - Built `gta6rt` (Windows 11, MSVC, Ninja, RelWithDebInfo). Not run: the full ctest suite and the translator suite (no shader or translator code changes). - `python -I scripts/check_no_game_data.py` on the changed files: clean. - Game observation, on a local build of `main` plus other local work: in the retail game on an RTX 5080 the read that failed now succeeds and the autosave error dialog no longer appears. No log lines or captures are quoted here. GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 (game observation only; the test needs no GPU). AI-assisted: yes (Claude Code, Opus 5.5) ### 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. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator rule) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 21:20:59 +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#2363
No description provided.