fix(libSceHttp): copy guest outputs through GuestCopy #19769
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19769"
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 gnavarro24 on 2026-11-13T22:21:57Z.
What
libSceHttphad 33 direct guest-pointer accesses across 22 exported functions. The scalar and struct outputs (memory pool stats, CA list, auth/cookie/gzip/nonblock enables, epoll handle, registered context ids, connection stats, cookie stats) were written straight through the guest pointer, so an unmapped output crashed the host instead of returningERROR_INVALID_VALUE. Each value is now stored throughGuestCopyOut_nid_no_patchvia a smallHttpGuesthelper that preserveserrno.Export.cpp:sceHttpGetMemoryPoolStats,sceHttpsGetCaList,sceHttpsFreeCaList,sceHttpGetAuthEnabled,sceHttpGetCookieEnabled,sceHttpGetRegisteredCtxIds,sceHttpGetConnectionStat.src/Options.cpp:sceHttpGetAutoRedirect,sceHttpGetNonblock,sceHttpGetAcceptEncodingGZIPEnabled,sceHttpGetEpoll.src/Cookies.cpp:sceHttpGetCookieStatscopies the whole struct in, sets its fields and copies it back, so the reserved word the console leaves alone is unchanged.python3 tools/guest_pointer_audit.py libSceHttpgoes from 33 direct accesses in 22 functions to 20 in 10.Left out on purpose:
sceHttpGetLastErrnostill writes its errno output in place. #9834, #11134 and #18515 rewrite its body, so it is left to them to avoid a conflict.sceHttpGetCookie(needs a stored cookie, which the tests cannot create offline),sceHttpParseResponseHeader(returns pointers into the guest header, so its input cannot be copied in without changing its result), and theUri.cppandClient.cppfunctions (overlap #12056 and #18346).These are recorded in
docs/dev/debt/libSceHttp.md.Tested
Linux x86-64 (Ubuntu 24.04, GCC 13.3.0, Ninja, Release,
-DBUILD_TESTING=ON), branch basemainbab5bc6b98. A newguest_http_guest_pointerstest (core/libs/tests/GuestHttpGuestPointers.cpp) passes; it calls each fixed export with an unmapped pointer (0x10) in place of the output and checksERROR_INVALID_VALUEwitherrnopreserved (set to71first), plus valid-pointer calls. The existing libSceHttp test binaries pass:guest_http,guest_http_options,guest_http_cookies, and allguest_http_state_*allocation modes (init,init-live,create,term 0-3).Negative control: the original
Export.cpp,src/Options.cppandsrc/Cookies.cppfrommainwith the new test in place:guest_http_guest_pointer_testsexits 139 (SIGSEGV) in each of 3 runs.python3 tools/check_conventions.py --base origin/mainreports no errors;git diff --checkis clean for the changed files.tools/pr_overlap.pycould not confirm the overlap with #9834, #11134 and #18515 because they conflict withmain. Compared by hand, their production changes touchsceHttpGetLastErrno(excluded here); their other hunks are test code and do not touch the functions changed here.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 PrivacyOnion on 2026-11-14T03:34:37Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
4820c34dd6:tools/check_conventions.pypassed;git diff --checkclean.guest_http_guest_pointer_testsbuilt cleanly.guest_http_guest_pointers):core/libs/prx/libSceHttp/Export.cpp,core/libs/prx/libSceHttp/src/Cookies.cpp,core/libs/prx/libSceHttp/src/Options.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me