fix(libSceNpUniversalDataSystem): copy event property keys, strings and binary values through checked reads #20813
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20813"
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 milescoviello on 2026-11-15T16:01:22Z.
What
The public event-property setters read guest strings and bytes in place:
sceNpUniversalDataSystemEventPropertyObjectSet*keys, throughcheckTarget'skey[0]and thenSet'sstd::string_view(key);EventPropertyObjectSetString/EventPropertyArraySetStringvalues (std::string(value));SetBinarybytes.An unmapped key, string or byte buffer faulted the host. Titles call these when they build trophy and statistic events.
What changes
Uds::CopyTextinNpUniversalDataSystem.hppcopies a guest string withCopyGuestString_nid_no_patchandSIZE_MAXas the cap, since the direct read had no length limit. It throwsstd::bad_allocfor a string too large for host memory, which is what thestd::stringconstruction it replaces did. The unbounded cap relies on #20678, which growsCopyGuestString's buffer by page, so this depends on it.checkTargetcopies the key, and each object setter then pointskeyat the host copy (key = name.c_str(), assigaltstackdoes withstack). TheSetlines are unchanged.SetBinarycopies its bytes with oneGuestCopyIn_nid_no_patch.Errors
SCE_NP_UNIVERSAL_DATA_SYSTEM_ERROR_INVALID_KEY, and an unreadable value or byte buffer returns..._NULL_VALUE. These are the codes a null one already returns, and nothing is stored.Related PRs
new_object/new_arrayandvalue_ptroutputs in these files. This PR doesn't touch those lines.IntRecord*builders inRecord.cpp.The debt entry goes in a fragment under
docs/dev/debt/changes/and marks the codes as host-safety fallbacks. Console behaviour here is not measured.Tested
Linux (Ubuntu 26.04.1), GCC 15.2, Release.
np_uds_events: newtestGuestPointerFaults.0x10) inputs return the codes above witherrnoleft at 71, and neither the object nor the array changes. Covered: keys forSetInt32,SetString,SetObjectandSetArray; object and array string values; object and array binary bytes.libSceNpUniversalDataSystemtests pass.EventPropertyObject.cppandEventPropertyArray.cppfrommainwith these tests die with SIGSEGV at address0x10. The long-string cases run first and pass there.git merge-treeis clean againstmain, #19606, #13606 and #20812.debt_fold.py --checkpass.tools/check_conventions.pypasses on the branch and this body.69869dbe56merged intomain56c87adbdc(Windows 11, i7-12700K, WinLibs GCC 15.2.0, Release):guest_copy_guest_string,np_uds_events, pass 2/2, three runs.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)Pull request closed