Repository navigation
fix(libSceHttp): copy sceHttpUriUnescape's input and outputs through guest copies - #21591
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
The change copies guest input and routes output writes through guest memory helpers; I found no verified blocking defect in the changed code.
What I ran
Reviewed head 0c7558005ed49253e320e882bdea135ae24aa2a7 against main. No commands or tests were run; I inspected the prepared diff, the changed lines, and the relevant helper implementations with repo_read.py.
Files read: core/libs/prx/libSceHttp/src/Uri.cpp (lines 70–155 and 280–390) and core/libs/tests/GuestHttp.cpp (lines 580–670). Both changed files listed in the manifest were read. No changed files were excluded.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed lines | passed | Both changed files inspected |
| Targeted source review | passed | Guest copy helpers and unescape path inspected |
| Tests | not run | Author reports guest_http passed |
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported test runs, negative control, and convention check were not independently run. Runtime behavior outside the inspected paths was not verified.
To get this to a good state
Nothing is required.
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 0c7558005e:
- Conventions:
tools/check_conventions.pypassed;git diff --checkclean. - Build:
guest_http_testsbuilt cleanly. - CTest (
guest_http,guest_http_uri_locale):1/2 Test #3615: guest_http_uri_locale ............ Passed 0.08 sec 2/2 Test #3614: guest_http ....................... Passed 0.38 sec 100% tests passed, 0 tests failed out of 2 - Negative control: with
core/libs/prx/libSceHttp/src/Uri.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.1/2 Test #3615: guest_http_uri_locale ............ Passed 0.04 sec 2/2 Test #3614: guest_http .......................***Exception: SegFault 1.70 sec 50% tests passed, 1 tests failed out of 2 - Code reading:
- Verified
core/libs/prx/libSceHttp/src/Uri.cpp:sceHttpUriUnescapechecks!input || (!out && !requiredSize)first, then callsCopyGuestCString(input, copied)which reads in page-bounded chunks and preserveserrno, returningERROR_INVALID_VALUEon unreadable guest memory. - Verified
core/libs/prx/libSceHttp/src/Uri.cpp: Both%hex-sequence validation and pre-1.0 SDK character set validation run unchanged againstsource(copied) before any writes tooutorrequiredSize. - Verified
core/libs/prx/libSceHttp/src/Uri.cpp: Whenoutis non-null andunescaped.size() >= capacity, up tocapacitydecoded bytes (without a null terminator) are written viaWriteGuestByteswhencapacity != 0, returningERROR_INVALID_VALUEif the write faults andERROR_OUT_OF_MEMORYotherwise without modifyingrequiredSize. - Verified
core/libs/prx/libSceHttp/src/Uri.cpp: On sufficient capacity,unescaped.size() + 1bytes including the null terminator are written viaWriteGuestBytes(out, ...), followed by writingsize(unescaped.size() + 1) torequiredSizeviaWriteGuestBytes(requiredSize, &size, sizeof(size)), returningERROR_INVALID_VALUEif either write fails. - Verified
core/libs/tests/GuestHttp.cpp: Added test cases cover unmapped (0x10)input,out, andrequiredSizepointers insceHttpUriUnescapeand verify the return code (ERROR_INVALID_VALUE) and partial/unmodified output state.
- Verified
Looks Good To Me
|
This branch is based on |
|
On current I manually compared the Current PR head |
…guest copies sceHttpUriUnescape read its input in place and wrote the decoded bytes and the required size straight through the caller's pointers. The input is now copied with CopyGuestCString and the result written with WriteGuestBytes; a bad pointer returns ERROR_INVALID_VALUE, and a short output still gets exactly capacity bytes with ERROR_OUT_OF_MEMORY. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0c75580 to
ad11e93
Compare
|
Thanks for checking. I rebased the branch onto |
|
@boykopovar — this PR is approved by MarcZX10 and PrivacyOnion, all applicable required checks pass, and GitHub reports it CLEAN/MERGEABLE. The reviewed implementation/test file blobs are unchanged at the current head. The submitting account cannot execute MergePullRequest; could a maintainer merge when convenient? |
|
Windows result for head Host: Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 (x86_64-ucrt-posix-seh, r6), Release, The tests this PR adds or extends, AI-assisted: yes (Claude Code), the runs and the numbers above are from this machine. |
|
Tested
AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports. |
|
Thanks @maskym for the Windows run. I've added it to the Tested section, linked to your comment. |
|
Thanks @ycbuzi for the full-suite Windows runs. I've added them to the Tested section, linked to your report. |
|
Rechecked against current upstream |
|
Thanks @malekaifa for rechecking this against current |
What
sceHttpUriUnescaperead itsinputin place, through astd::string_viewthat measured it withstrlen. It also wrote the decoded bytes intooutone at a time and stored*requiredSizedirectly. So an unreadable input, or an unwritableoutorrequiredSize, crashed the host. The other URI helpers inUri.cppalready go through the file'sCopyGuestCStringandWriteGuestBytes, assceHttpUriMergedoes.Now:
CopyGuestCString, in page-bounded chunks, and both validation passes run on the copy.WriteGuestBytes, andrequiredSizeis written the same way.errnois kept.ERROR_INVALID_VALUE(0x804311FE), the result this export already gives for a null input.What stays the same:
ERROR_INVALID_URLchecks and their order: malformed%sequences first, then the pre-1.0 SDK character set.outstill returnsERROR_OUT_OF_MEMORYwith exactlycapacitydecoded bytes written and no terminator, as the old per-byte loop left it. The existingguest_httpcases pin this.requiredSizeis written only on success.Tested
Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release,
-DBUILD_TESTING=ON:guest_httpgains three cases:0x10) input returns0x804311FE, and leavesoutandrequiredSizeunchanged;outreturns0x804311FEand leavesrequiredSizeunchanged;requiredSizereturns0x804311FEafteroutreceived"a b".guest_httppasses, 3 runs of 3, including the existing unescape table and the short-buffer cases. Rerun after rebasing ontomain3ebf5692c0(headad11e93604): still 3 of 3, and the negative control below still fails the same way.main'sUri.cppand the new cases,guest_httpends infatal SIGSEGV (code 1) at address 0x0000000000000010.tools/check_conventions.pypasses on the branch and this body.ad11e93604merged intomain56c87adbdc(Windows 11, i7-12700K, WinLibs GCC 15.2.0, Release):guest_http,guest_http_uri_locale, pass 2/2, three runs.ad11e93604merged intomainon GitHub-hosted Windows Server 2022 and 2025 runners (WinLibs GCC 15.2.0): nothing fails that doesn't also fail onmainon the same runner.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)CopyGuestCStringandWriteGuestBytes, is merged)