runtime: reject a null blob name in XGameSaveReadBlobData #1554
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1561"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by RenzoWit35 on 2026-11-24T14:00:17Z.
Change
src/xgameruntime_shim.cppis the fixture-only XGameRuntime shim. ItsXGameSaveReadBlobDataimplementation (game_save_read_blob_data) refused a null name list withE_INVALIDARG, but passed each element of the list unchecked tofind_blob, which callsstd::strcmp(blob.name, name)for every live blob of the container. A null element was therefore dereferenced as soon as the container held one live blob: an access violation inside anoexceptfunction, raised while the shim's shared lock was held.requestedentries of the list next to its existing argument check, before the lock is taken, and returnsE_INVALIDARGfor a null entry.*count_of_blobsstays 0 and nothing is written to the caller's buffer. The export wrapper records the result in the shim log like every other return of this function.E_INVALIDARGwas chosen because the function already returns it for its other bad arguments and because the write path (XGameSaveSubmitBlobWrite, throughvalid_blob_name) refuses a null name with the same code. What the GDK implementation returns for a null entry was not verified.HRESULT_FROM_WIN32(ERROR_NOT_FOUND). No other validation was added.ERROR_NOT_FOUND(strcmpwas never reached) and now givesE_INVALIDARG; a null entry combined with a closed or expired container handle now givesE_INVALIDARGinstead ofE_HANDLE/E_GS_HANDLE_EXPIRED, the same order the function already uses for a null buffer.The input needs a live blob to show the defect, which is why the test reads from the container that already holds
player.bin.docs/experiments.mddoes not list the refused inputs of this call, so it is not changed.Verification
Environment: Windows 11 x64, VS Build Tools 2026 (MSVC 14.51), Windows SDK 26100, Ninja,
devpreset (Debug), Python 3.14.5. Base:origin/mainat60c72330.Regression check, added to the existing
tests/xgameruntime_contracts_check.cpp(testxgameruntime_contracts, no new target): afterplayer.binis committed toslot-a, it callsXGameSaveReadBlobDatawith{nullptr}(count 1) and with{"player.bin", nullptr}(count 2) into a zeroed 512-byte buffer and requiresE_INVALIDARG,count == 0and an all-zero buffer. TheXGameSaveCreateContainercall that follows takes the exclusive lock, so a leaked shared lock would hang the test (30 s timeout). The log scan now also requires anXGameSaveReadBlobDataentry withE_INVALIDARG, next to the existingERROR_NOT_FOUNDcontrol, and the expected log length goes from 34 to 36 entries (ring capacity 64, test buffer 48).Commands, from
<repo>in PowerShell:Observed with the change:
xgameruntime contracts: user=implemented game-save=implemented reopen=ok stale=E_GS_HANDLE_EXPIRED negative=E_NOTIMPL x2 PASS100% tests passed, 0 tests failed out of 5(xgameruntime_thunks,xgameruntime_contracts,xgameruntime_pls_xpackage,xgameruntime_identity,xgameruntime_preflight_stub_refused)xgameruntime table: exports=28 ... duplicate_control=detected PASSNegative control: the new check built against the unmodified shim source (
git checkout origin/main -- src/xgameruntime_shim.cpp, rebuildxgameruntime_shim,ctest --test-dir out/build/dev --no-tests=error -R '^xgameruntime_contracts$' -V):1/1 Test #50: xgameruntime_contracts ...........***Exception: SegFault0% tests passed, 1 tests failed out of 1,50 - xgameruntime_contracts (SEGFAULT)xgameruntime_contracts_check.exedirectly with the same three arguments ends with exit code0xC0000005and prints nothing. The call is not guarded in the test, so the failure on the old code is the crash itself.After restoring the fix and rebuilding, the five tests pass again as listed above.
Rebased onto
origin/mainata3633d4dbefore opening this pull request and re-run there: shim and check rebuilt,xgameruntime_contracts,xgameruntime_thunks,xgameruntime_pls_xpackageandxgameruntime_identitypassed.Not run: the full test suite, the
prpreset, a Release build, GPU and hardware tests. The two code-reading consequences listed under Change were not exercised.Evidence and follow-up
No open pull request touches
src/xgameruntime_shim.cpp,tests/xgameruntime_contracts_check.cppor any other path containingxgameruntime(checked withgh pr list --state open --limit 200 --json number,title,files, 47 open pull requests at the time). A search of open issues and pull requests forXGameSaveReadBlobDatareturned nothing. No issue is linked.The crash needs a caller that passes a null entry in the name list; the existing fixtures never did, so this is a robustness fix for the shim's own contract, not a change observed to matter for any program.
AI-assisted.