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

Manually merged
github merged 2 commits from gh-pr/842/head into gh-pr/842/base 2026-11-26 09:24:05 +00:00
Owner

@⁠c4k3ss on GitHub · 2026-11-24 14:27 UTC · original
c4k3ss:rt/pls-get-path-size → main · +12 −3 · 2 files · 2 commits · merged 2026-11-24 21:26 UTC

Claimed in the coordination issue as: RT-712 (#14), 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)
**@⁠c4k3ss** on GitHub · 2026-11-24 14:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/842) `c4k3ss:rt/pls-get-path-size` → `main` · +12 −3 · 2 files · 2 commits · merged 2026-11-24 21:26 UTC Claimed in the coordination issue as: RT-712 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14), 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)
The (size, buffer, used) convention of the XSystem id getters: a short buffer learns the path length with its NUL
in *path_used, the buffer stays untouched, the HRESULT is unchanged.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
The XSystem id getters (XSystemGetConsoleId, copy_id) return
ERROR_INSUFFICIENT_BUFFER without setting *used, so they are not the
precedent the comment named. Say what the code does instead: the buffer
is untouched and *path_used gets the path length with its NUL, the value
slot 3 (pls_get_path_size) reports. Comment only, no behavior change.

Noted by moffington in review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:24:04 +00:00
github manually merged commit d72a0c9f50 into gh-pr/842/base 2026-11-26 09:24:05 +00:00
Author
Owner

@⁠moffington on GitHub · 2026-11-24 15:43 UTC · original

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.

**@⁠moffington** on GitHub · 2026-11-24 15:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/842#issuecomment-7136515202) 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.
Author
Owner

@⁠c4k3ss on GitHub · 2026-11-24 17:55 UTC · original

@⁠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.

**@⁠c4k3ss** on GitHub · 2026-11-24 17:55 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/842#issuecomment-7139889795) @⁠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.
Author
Owner

@⁠QemmHD on GitHub · 2026-11-24 21:26 UTC · original

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).

**@⁠QemmHD** on GitHub · 2026-11-24 21:26 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/842#issuecomment-7144938499) 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).
This discussion has been locked. Commenting is limited to contributors.
No description provided.