xgameruntime: XPersistentLocalStorageGetPath reports the required size on a short buffer (RT-712) #842

Merged
c4k3ss merged 2 commits from upstream-pr/842 into main 2026-11-24 21:26:45 +00:00
c4k3ss commented 2026-11-24 14:27:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by c4k3ss on 2026-11-24T14:27:29Z.


Claimed in the coordination issue as: RT-712 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134292009), carried over from the upstream repository, where it was open and independently tested when the repository went private.

What and why

pls_get_path (XPersistentLocalStorageGetPath, slot 4 of XPersistentLocalStorageImpl in runtime/shims/xgameruntime.cpp) answered a short buffer with ERROR_INSUFFICIENT_BUFFER and *path_used = 0, so a title that passes a small buffer with a non-null used pointer learns nothing about the size it needs. Slot 3 (pls_get_path_size) already reports that size; this makes pls_get_path report it on the short-buffer error too: on a short buffer *path_used is the path length with its NUL, the buffer is untouched and the HRESULT is unchanged. The success path is unchanged.

Tested

runtime/test/xgameruntime_test.cpp, in the existing XPersistentLocalStorageImpl block: the short-buffer case checks used == size (slot 3's answer) and that the two-byte buffer is left alone; a buffer one byte short reports the same size; a null used pointer on a short buffer is tolerated.

  • Windows 11 26200, MSVC 14.44, RelWithDebInfo, Ninja, on main d0da7dade: ctest -R ^xgameruntime$ passes with the change. Negative control (this main's xgameruntime.cpp with the new test): xgameruntime_test: 2 of 160 checks failed, the two new size checks.
  • Upstream, the same change had one independent pass (RTX 2060, Windows 10, clang-cl) including the same negative control.

GPUs tested: n/a (CPU-only shim and test)

AI-assisted: yes (Claude Code); built and tested on the machine above.

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. (not a translator change)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474060430 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/842). Originally posted by [c4k3ss](https://github.com/c4k3ss) on 2026-11-24T14:27:29Z. --- Claimed in the coordination issue as: RT-712 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7134292009), carried over from the upstream repository, where it was open and independently tested when the repository went private. ### What and why `pls_get_path` (`XPersistentLocalStorageGetPath`, slot 4 of `XPersistentLocalStorageImpl` in `runtime/shims/xgameruntime.cpp`) answered a short buffer with `ERROR_INSUFFICIENT_BUFFER` and `*path_used = 0`, so a title that passes a small buffer with a non-null `used` pointer learns nothing about the size it needs. Slot 3 (`pls_get_path_size`) already reports that size; this makes `pls_get_path` report it on the short-buffer error too: on a short buffer `*path_used` is the path length with its NUL, the buffer is untouched and the `HRESULT` is unchanged. The success path is unchanged. ### Tested `runtime/test/xgameruntime_test.cpp`, in the existing `XPersistentLocalStorageImpl` block: the short-buffer case checks `used == size` (slot 3's answer) and that the two-byte buffer is left alone; a buffer one byte short reports the same size; a null `used` pointer on a short buffer is tolerated. - Windows 11 26200, MSVC 14.44, RelWithDebInfo, Ninja, on `main` `d0da7dade`: `ctest -R ^xgameruntime$` passes with the change. Negative control (this `main`'s `xgameruntime.cpp` with the new test): `xgameruntime_test: 2 of 160 checks failed`, the two new size checks. - Upstream, the same change had one independent pass (RTX 2060, Windows 10, clang-cl) including the same negative control. GPUs tested: n/a (CPU-only shim and test) AI-assisted: yes (Claude Code); built and tested on the machine above. ### 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. (not a translator change)
moffington commented 2026-11-24 15:43:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by moffington on 2026-11-24T15:43:50Z.


Reviewed c156e77c4 against d0da7dade on Linux.

An independent differential harness testing the extracted pls_get_path and pls_get_path_size functions with ASan/UBSan and guard pages produced:

  • Baseline: 22/26 passed.
  • HEAD: 26/26 passed.

Verified required-size reporting, NUL termination, zero-length/undersized buffers, null pointers, and no unintended buffer writes.

Minor non-blocking note: the comment about XSystem ID getters reporting the required size on insufficient buffers appears inaccurate. Neither XSystemGetConsoleId nor copy_id currently does this.

Clean merge-tree against a28927849. Full Windows runtime tests were not run locally due to the existing MinGW SEH compilation issue.

LGTM.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7136515202 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/842#issuecomment-7136515202). Originally posted by [moffington](https://github.com/moffington) on 2026-11-24T15:43:50Z. --- Reviewed `c156e77c4` against `d0da7dade` on Linux. An independent differential harness testing the extracted `pls_get_path` and `pls_get_path_size` functions with ASan/UBSan and guard pages produced: - Baseline: 22/26 passed. - HEAD: 26/26 passed. Verified required-size reporting, NUL termination, zero-length/undersized buffers, null pointers, and no unintended buffer writes. Minor non-blocking note: the comment about XSystem ID getters reporting the required size on insufficient buffers appears inaccurate. Neither `XSystemGetConsoleId` nor `copy_id` currently does this. Clean merge-tree against `a28927849`. Full Windows runtime tests were not run locally due to the existing MinGW SEH compilation issue. LGTM.
c4k3ss commented 2026-11-24 17:55:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by c4k3ss on 2026-11-24T17:55:01Z.


@moffington thanks for the review and the harness run. You're right about the comment: XSystemGetConsoleId and copy_id return ERROR_INSUFFICIENT_BUFFER without setting *used, so they weren't the precedent it named. Fixed in d72a0c9f5 (comment only, no behavior change). It now says what the code does: the short buffer is left untouched and *path_used gets the path length with its NUL, the value slot 3 reports. I corrected the same claim in the PR description.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7139889795 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/842#issuecomment-7139889795). Originally posted by [c4k3ss](https://github.com/c4k3ss) on 2026-11-24T17:55:01Z. --- @moffington thanks for the review and the harness run. You're right about the comment: `XSystemGetConsoleId` and `copy_id` return `ERROR_INSUFFICIENT_BUFFER` without setting `*used`, so they weren't the precedent it named. Fixed in d72a0c9f5 (comment only, no behavior change). It now says what the code does: the short buffer is left untouched and `*path_used` gets the path length with its NUL, the value slot 3 reports. I corrected the same claim in the PR description.
QemmHD commented 2026-11-24 21:26:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T21:26:43Z.


Merging.

Why merged: RT-712: XPersistentLocalStorageGetPath reports the required size on a short buffer and leaves the buffer untouched, as the GDK documents. moffington's ASan/UBSan harness passes 26/26, and their comment nit is fixed.

Why it's good: There are no writes into the caller's buffer on that path. xgameruntime passes both plain and under validation.

Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main 66d4f5aa3, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative of this batch (13 PRs) on main 0b45fdc21: the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 314/316 with the same 11 skips. The only failures are main's: d3d12_depth_resolve (pre-existing) and d3d12_close_parity (the #510 regression, fixed by #1286). All d3d12_* tests under validation show 0 VUIDs. git merge-tree against current main 6261ca916: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7144938499 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/842#issuecomment-7144938499). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T21:26:43Z. --- Merging. **Why merged:** RT-712: XPersistentLocalStorageGetPath reports the required size on a short buffer and leaves the buffer untouched, as the GDK documents. moffington's ASan/UBSan harness passes 26/26, and their comment nit is fixed. **Why it's good:** There are no writes into the caller's buffer on that path. xgameruntime passes both plain and under validation. Tested on Windows 11 / RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0. Merged alone onto main 66d4f5aa3, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative of this batch (13 PRs) on main 0b45fdc21: the repo-consistency set gives 573 passed / 5 skipped / 0 failed, compileall is clean, and full ctest is 314/316 with the same 11 skips. The only failures are main's: d3d12_depth_resolve (pre-existing) and d3d12_close_parity (the #510 regression, fixed by #1286). All d3d12_* tests under validation show 0 VUIDs. git merge-tree against current main 6261ca916: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls or CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
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
ProjectLeonida/mandy!842
No description provided.