fix(libSceSaveData.native): validate pattern termination in sceSaveDataDirNameSearch #12650
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12650"
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 boykopovar/AnyPS5. Originally posted by slopgobblercobbler on 2026-10-29T00:12:12Z.
What
Validates null-termination of
cond->dir_nameindirNameSearch(sceSaveDataDirNameSearchandsceSaveDataDirNameSearch2), returningSAVE_DATA_ERROR_PARAMETERif the 32-byte fixed-size pattern array is not null-terminated within its bounds.Without this check, an unterminated pattern string passed in
dir_namecauses unbounded reads / buffer overreads indir_name_matchpast the 32-bytedatabuffer. Other save data APIs such assceSaveDataMount3,sceSaveDataDelete,sceSaveDataConvert, andsceSaveDataBackupsimilarly enforce null-termination of 32-byte directory names usingstd::memchr.Tested
core/libs/tests/GuestSaveDataSearch.cpp(CheckNullArguments). Confirmed that passing an unterminated 32-byte directory pattern to bothsceSaveDataDirNameSearchandsceSaveDataDirNameSearch2returnsSaveDataErrorParameter(0x809f0001/-2137063424).python tools/check_conventions.py --base upstream/main --head HEAD(0 findings).guest_savedata_searchpassed 3/3; negative control confirmed failing against baseExport.cpp.46b89c8f4fmerged ontoed1e0ed08f,guest_savedata_search(3/3), all 7guest_savedata_*suites, andpublic_headerspassed; control run confirmed failing at unterminateddir_namecheck.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-29T01:15:25Z.
Review: COMMENTED
Reviewed on macOS arm64 (Apple clang,
-fsanitize=address,undefined -fno-sanitize-recover=all), standaloneExport.cpp+GuestSaveDataSearch.cpp+ a 4-symbol shim (GetAppTitleId_nid_postfix,Add/RemovePathAlias_nid_no_patch,NotImplemented_nid_no_patch), at 346f268170.guest_savedata_searchpasses. Withmain'sExport.cppit fails atunterminated dir_name in sceSaveDataDirNameSearch returns PARAMETER, so the new test does detect the bug.APS5_SAVEDATA_TRACE=1the head test aborts (rc 134): ASan reportsstack-buffer-overflowinfprintf, called fromsceSaveDataDirNameSearchExport.cpp:482. The wrapper logspattern=%sfromcond->dir_name->dataafterdirNameSearchhas returned PARAMETER for the unterminated name (unterminatedPatternis [224, 256) in the frame).sceSaveDataDirNameSearch2at L1004 has the same problem.sceSaveDataMount3's trace (L672) already bounds its name with%.*s. Without the env var only the first 3 trace lines print, so CI does not see this.memchr(..., sizeof(data) - 1)survives, because no test passes a 32-byte name whose terminator is in its last byte.The diff below bounds both traces the way Mount3 does and adds the last-byte acceptance case. With it, the test passes with and without
APS5_SAVEDATA_TRACE=1, all 3 guard mutants are killed, andcheck_conventionsandgit merge-treeagainst main3a2b919816are clean.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T15:38:47Z.
Review: COMMENTED
First Linux run of this head (the thread has Windows and a standalone macOS harness).
Ubuntu 26.04, i7-8700, GCC 15.2, Release,
BUILD_TESTING=ON. Head46b89c8f4fmerged (--no-commit) onto currentmained1e0ed08f; the merge is clean.guest_savedata_search: passes 3/3.guest_savedata_*tests pass.public_headers: passes.Export.cppfrommainand this PR's test kept,guest_savedata_searchfails 3/3 atunterminated dir_name in sceSaveDataDirNameSearch returns PARAMETER.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.