Skip to content

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

Merged
QemmHD merged 2 commits into
ProjectLeonida:mainfrom
c4k3ss:rt/pls-get-path-size
Nov 24, 2026
Merged

QemmHD merged 2 commits into
ProjectLeonida:mainfrom
c4k3ss:rt/pls-get-path-size

Conversation

@c4k3ss

@c4k3ss c4k3ss commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-712 (#14 (comment)), 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)

…e on a short buffer (RT-712)

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 <noreply@anthropic.com>
@c4k3ss
c4k3ss marked this pull request as ready for review November 24, 2026 14:38
@moffington

Copy link
Copy Markdown
Contributor

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.

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 <noreply@anthropic.com>
@c4k3ss

c4k3ss commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

@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 d72a0c9 (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

QemmHD commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

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 66d4f5a, its ctests pass both plain and with LEONIDA_VK_VALIDATION=1. Cumulative of this batch (13 PRs) on main 0b45fdc: 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 6261ca9: 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
QemmHD merged commit 1988ff6 into ProjectLeonida:main Nov 24, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants