feat(libSceHttp): add the cookie store #10535
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10535"
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 noamroger on 2026-10-24T08:48:19Z.
What
Implements the libSceHttp cookie store:
sceHttpAddCookie,sceHttpGetCookie,sceHttpGetCookieStats,sceHttpSetCookieMaxNum,sceHttpSetCookieMaxNumPerDomain,sceHttpSetCookieMaxSizeandsceHttpSetCookieTotalMaxSize.sceHttpCookieFlushnow empties the store.sceHttpTermdrops. The code is in a newsrc/Cookies.cpp, soExport.cpponly loses the stubs, which keeps conflicts with #9834 and #10167 small.libSceHttp.sprx, measured natively by a reviewer (see the review thread):INVALID_IDwithout a live context, any URL scheme,0x804321FEfor a URL without a host or aDomainthe host does not end with,INVALID_VALUEfor an empty cookie or aDomainwith too few labels (two under com/org/net/edu/gov/mil/int, three elsewhere), cookies without a name or a value kept, cookies withoutDomainsent to subdomains, the default path keeping its slash andPathas a plain prefix.sceHttpGetCookie(ctx, url, cookie, required, prepared)returnsSecurecookies only forhttps://, writesa=1; b=2, a NUL, a space and a NUL (required= length + 3), returnsNOT_FOUND(0x80431025) without a match, and on a short buffer returnsOUT_OF_SIZE(0x80431104) with the cookies that fit written and terminated. Longer paths come first.OUT_OF_SIZE), 50 cookies per domain, 3000 cookies and 81920 bytes in total. Past the count or total-size limit the 10 oldest cookies go at once (every older one if fewer) and the new one stays; past the per-domain limit the oldest of the domain goes. Every setter andsceHttpCookieFlushempty the store and keep the peaks.sceHttpGetCookieStatswrites the 32-byte layout already ininclude/Http.hpp, leaving bytes 12-15 untouched; the size is name + value + domain (without its dot) + path + 5.Domainspelled differently is a different cookie.sceHttpCookieFlushreturnsINVALID_IDwithout a live context, as measured;GuestHttpis updated for it.sceHttpCookieExport,sceHttpCookieImportandsceHttpSetCookieSendCallbackstill throw; they are left for a follow-up.Tested
Linux (Ubuntu 24.04, GCC 13.3). libSceHttp was built from its sources, and the guest tests were linked against it. The new
GuestHttpCookiespasses, as doGuestHttpOptionsandGuestHttpResponseHeader.GuestHttpneeds the real libc process-parameter fixture and was not run locally. A reviewer built it on Windows 11 (WinLibs GCC 15.2.0, mingw-w64) and foundERROR_NOT_FOUNDclashing with thewinerror.hmacro; it is nowERROR_HTTP_NOT_FOUND, and with that renameguest_http_cookiespassed 3 of 3 runs there.GuestHttpCookiescovers every behaviour listed above against the console results: errors and their precedence, therequiredand partial-write layout, matching and ordering, domain rules, deletion and the date formats, thesizebound, each default limit and setter, eviction by age and the stats layout and size. It also passes under ASan and UBSan.Not run on a PS5 by me; the expectations come from the reviewer's firmware 13.42 measurements.
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)Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T11:07:05Z.
Review: CHANGES_REQUESTED
Found a reproducible overflow in
parseMaxAge(). The saturation threshold0x7FFFFFFFFFseconds is much larger than the representablesystem_clockrange on this Linux host (nanosecond ticks). A valid value such asMax-Age=10000000000is below that threshold, so it reachesnow + std::chrono::seconds{seconds}; converting the seconds to the clock duration overflows signed 64-bit nanoseconds. I compiled the exact PR-headCookies.cppwith a tinyparseMaxAge("10000000000", Clock::now())probe under-fsanitize=undefined -fno-sanitize-recover=all; UBSan reports signed integer overflow inchrono.hand aborts. Please clamp/check against the clock’s representable remaining range before adding, and add a large-but-valid Max-Age regression (ideally run the focused test under UBSan). This is in addition to the contributor-reported cookie test suite.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:24:49Z.
Review: CHANGES_REQUESTED
The reported clock-range overflow is addressed on the current head: Max-Age is bounded to the remaining clock range, and Expires is clamped before conversion. The focused regression and UBSan run are author-reported; hosted structural checks pass, while product builds are skipped. Merge coordination is still needed for two concrete file overlaps. #9630 adds a separate allocation-regression target to the same libSceHttp/CMakeLists.txt section where this PR registers GuestHttpCookies, and #6044 reorganizes test paths/registrations. Please agree with those authors on an order or rebase strategy, record it in Depends on/your PR notes, and ensure both test registrations survive the composition. I manually checked #9822/#9826: their libSceHttp change is sceHttpSetCookieEnabled, separate from the cookie store exports here.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T18:29:45Z.
Review: COMMENTED
Re-checked — new head, integration evidence pending
The cookie implementation and its earlier requested fixes are in place, but I cannot verify the final composition with the still-open #9630 dependency at its current head.
What I ran
Reviewed exact PR head
1fac04e35ee1c594063d9243d08a48445c35a675against PR base4017310678562c63594d99b8f45db2d68b9aaa6c; the individual preview against currentmainca073ec3ad0d766ea9f4658e418a5c977001a353is clean. Environment: Linux x86-64, Python 3.11.2, Git 2.39.5. I did not build or compile locally.Results
cff855f72618fbee7bde0b866609854017ca5f9b; its current head is not included in #10535 and overlapsCMakeLists.txt,Export.cpp, and the HTTP debt file.Unedited relevant output
Conventions:
Stack report:
Sources
Not verified
The author’s Linux, Windows, and sanitizer results were not independently reproduced. In particular, the earlier combined-stack test report predates the current #9630 head; #9630’s latest report also says it does not claim a new combined-stack run. I did not build or run the composed #9630 + #10535 tests. This is a remaining integration-evidence gap, not a code defect found in this review.
To get this to a good state
After #9630 lands, rebase/compose #10535 in the agreed order and run the allocation-regression target together with the cookie tests, preserving both CMake registrations. I will recheck the resulting head and evidence.