feat(libcurl): implement string lists and URL escaping #14429

Merged
bipinkrish merged 2 commits from upstream-pr/14429 into main 2026-11-07 04:48:07 +00:00
bipinkrish commented 2026-11-01 12:35:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by bipinkrish on 2026-11-01T12:35:47Z.


What

Implements curl_slist_append, curl_slist_free_all, curl_free, curl_easy_escape, curl_easy_unescape, curl_escape and curl_unescape with typed System V ABI declarations and the 16-byte LP64 list layout.

Lists copy strings, retain insertion order, preserve the original list when allocation fails, and release both strings and nodes. Escaping uses ASCII unreserved bytes and uppercase percent encodings; unescaping preserves malformed escapes and literal plus signs, accepts binary data with explicit lengths, and reports decoded lengths including embedded NULs. Allocations and frees use the guest libc heap.

Signatures and behavior follow curl 8.10.1's public API and escape.c / slist.c, independently reimplemented without adding third-party code. The console version and behavior are unverified and recorded in docs/dev/debt/libcurl.md. Null strings whose behavior differs between curl versions throw through NotImplemented_nid_no_patch; negative lengths return null without reading input. Custom curl allocators remain unavailable because curl_global_init_mem still throws.

Rebased onto main 28154f27a0 after #14337 merged. Both string-comparison exports are preserved. The curl library CMake file registers both guest_curl and guest_curl_strings; the debt inventory lists the 76 remaining unconditional stubs. The landing-order dependency is satisfied.

Tested

Rebase validation at 257a1142da on 2026-11-07

  • Rebuilt the actual curl and current-main libc CMake targets in an isolated focused harness with GCC 13.3.0. Curl and both tests compile with -Wall -Wextra -Werror.
  • ctest --test-dir /tmp/anyps5-curl-check/build -R '^guest_curl' --output-on-failure passed both guest_curl and guest_curl_strings.
  • Public-header audit passed for 407 libraries and 30,771 exports. All 76 debt-table rows match the remaining unconditional stub bodies.
  • git diff --check and conventions against upstream/main passed. The required --base origin/main run reports an existing upstream commit-subject violation at e62a0f2604. Checking unchanged upstream/main against the same fork base reports the same error.
  • This rebase validation uses focused Linux builds. Fresh hosted CI is pending.

Earlier validation before the rebase

Ubuntu 24.04.4, x86-64, GCC 13.3.0. No game, homebrew, PS5 system library, firmware dump or console was used.

  • Verified head 71fc1c3f22376233ade2ce69215741677e504158: after removing the throw assertions, rebuilt and reran guest_curl in Release and under ASan/UBSan with leak detection; both passed. Strict compilation and conventions checks were also rerun successfully. The runtime implementation and debt notes are unchanged. Null strings with nonnegative lengths and curl_slist_append(nullptr, nullptr) are deliberately not tested; implemented escaping, list ownership, negative-length, allocation-failure and allocation/output-length checks remain.
  • Full project configuration with BUILD_TESTING=ON; built libcurl, libc, libkernel and guest_curl_tests. Release ctest --test-dir build -R '^guest_curl$' --output-on-failure: passed.
  • Separate Debug build with ANYPS5_ENABLE_ASAN=ON and -fsanitize=undefined; the same CTest passed with ASAN_OPTIONS=detect_leaks=1 and UBSAN_OPTIONS=halt_on_error=1. Leak detection ran outside the sandbox because it needs process inspection.
  • Committed tests cover all 256 input bytes, upper/lowercase hex, binary and NUL-terminated lengths, embedded NULs, malformed/truncated escapes, unchanged plus signs, ignored handles, guarded input boundaries, list ownership/order/independence, negative lengths, and every allocation failure in list creation/append and escaping. Outstanding guest allocations return to zero, including after failure.
  • Separate differential probe: 145,468 cases matched installed curl 8.5.0, including all 65,536 percent-triplet byte pairs and 5,000 deterministic random byte strings across explicit/NUL-terminated/negative lengths and both legacy wrappers. List lifecycle behavior also matched. Null strings are excluded from that oracle because 8.5.0 faults whereas 8.10.1 returns null.
  • Negative controls compiled from temporary copies: lowercase escaping and a leak on second list-allocation failure each made the committed test abort at the relevant assertion. Repository sources were not mutated for these controls.
  • g++ -std=c++20 -Wall -Wextra -Werror -Icore/libs -fsyntax-only on the changed implementation and new test: passed.
  • python3 core/libs/tests/test_public_headers.py --audit-only: passed (399 libraries, 26,227 exports).
  • python3 tools/check_conventions.py --base origin/main: zero errors; eight existing debt-length warnings in unrelated upstream files. git diff --check: passed.

Original pre-rebase overlap check: ran python3 tools/pr_overlap.py --branch codex/curl-lists-url-escaping --repo boykopovar/AnyPS5 --jobs 8 against 1,666 open PR heads. No shared exports. It reports textual overlap with #14337 at Export.cpp:3 and docs/dev/debt/libcurl.md:5; merge ordering is declared above. The checker exits 2 because 12 existing PR branches conflict with main and share core/libs/CMakeLists.txt. I manually compared every flagged branch's diff from its merge base: #5021 changes macOS linker/rpath setup; #7275 adds render_override tests; #8650 adds VR tracker tests; #9156 adds pthread attribute tests; #9162 adds wait3/wait4 tests; #9293/#9297/#9302 add semaphore/message queue tests; #9383 adds rtld_printf tests; #12642 adds pthread suspend tests; #13253 adds dup tests; #13256 adds nanosleep tests. None touches the insertion before guest_vorbis_dec_tests, the curl target, or these curl exports.

Not tested: Windows/macOS execution, any console comparison, strings larger than INT_MAX, or the full repository test suite.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5107383628 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14429). Originally posted by [bipinkrish](https://github.com/bipinkrish) on 2026-11-01T12:35:47Z. --- ### What Implements `curl_slist_append`, `curl_slist_free_all`, `curl_free`, `curl_easy_escape`, `curl_easy_unescape`, `curl_escape` and `curl_unescape` with typed System V ABI declarations and the 16-byte LP64 list layout. Lists copy strings, retain insertion order, preserve the original list when allocation fails, and release both strings and nodes. Escaping uses ASCII unreserved bytes and uppercase percent encodings; unescaping preserves malformed escapes and literal plus signs, accepts binary data with explicit lengths, and reports decoded lengths including embedded NULs. Allocations and frees use the guest libc heap. Signatures and behavior follow curl 8.10.1's public API and [escape.c](https://github.com/curl/curl/blob/curl-8_10_1/lib/escape.c) / [slist.c](https://github.com/curl/curl/blob/curl-8_10_1/lib/slist.c), independently reimplemented without adding third-party code. The console version and behavior are unverified and recorded in `docs/dev/debt/libcurl.md`. Null strings whose behavior differs between curl versions throw through `NotImplemented_nid_no_patch`; negative lengths return null without reading input. Custom curl allocators remain unavailable because `curl_global_init_mem` still throws. Rebased onto main `28154f27a0` after #14337 merged. Both string-comparison exports are preserved. The curl library CMake file registers both `guest_curl` and `guest_curl_strings`; the debt inventory lists the 76 remaining unconditional stubs. The landing-order dependency is satisfied. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Rebase validation at `257a1142da` on 2026-11-07 - Rebuilt the actual curl and current-main libc CMake targets in an isolated focused harness with GCC 13.3.0. Curl and both tests compile with `-Wall -Wextra -Werror`. - `ctest --test-dir /tmp/anyps5-curl-check/build -R '^guest_curl' --output-on-failure` passed both `guest_curl` and `guest_curl_strings`. - Public-header audit passed for 407 libraries and 30,771 exports. All 76 debt-table rows match the remaining unconditional stub bodies. - `git diff --check` and conventions against `upstream/main` passed. The required `--base origin/main` run reports an existing upstream commit-subject violation at `e62a0f2604`. Checking unchanged `upstream/main` against the same fork base reports the same error. - This rebase validation uses focused Linux builds. Fresh hosted CI is pending. Earlier validation before the rebase Ubuntu 24.04.4, x86-64, GCC 13.3.0. No game, homebrew, PS5 system library, firmware dump or console was used. - Verified head `71fc1c3f22376233ade2ce69215741677e504158`: after removing the throw assertions, rebuilt and reran `guest_curl` in Release and under ASan/UBSan with leak detection; both passed. Strict compilation and conventions checks were also rerun successfully. The runtime implementation and debt notes are unchanged. Null strings with nonnegative lengths and `curl_slist_append(nullptr, nullptr)` are deliberately not tested; implemented escaping, list ownership, negative-length, allocation-failure and allocation/output-length checks remain. - Full project configuration with `BUILD_TESTING=ON`; built `libcurl`, `libc`, `libkernel` and `guest_curl_tests`. Release `ctest --test-dir build -R '^guest_curl$' --output-on-failure`: passed. - Separate Debug build with `ANYPS5_ENABLE_ASAN=ON` and `-fsanitize=undefined`; the same CTest passed with `ASAN_OPTIONS=detect_leaks=1` and `UBSAN_OPTIONS=halt_on_error=1`. Leak detection ran outside the sandbox because it needs process inspection. - Committed tests cover all 256 input bytes, upper/lowercase hex, binary and NUL-terminated lengths, embedded NULs, malformed/truncated escapes, unchanged plus signs, ignored handles, guarded input boundaries, list ownership/order/independence, negative lengths, and every allocation failure in list creation/append and escaping. Outstanding guest allocations return to zero, including after failure. - Separate differential probe: 145,468 cases matched installed curl 8.5.0, including all 65,536 percent-triplet byte pairs and 5,000 deterministic random byte strings across explicit/NUL-terminated/negative lengths and both legacy wrappers. List lifecycle behavior also matched. Null strings are excluded from that oracle because 8.5.0 faults whereas 8.10.1 returns null. - Negative controls compiled from temporary copies: lowercase escaping and a leak on second list-allocation failure each made the committed test abort at the relevant assertion. Repository sources were not mutated for these controls. - `g++ -std=c++20 -Wall -Wextra -Werror -Icore/libs -fsyntax-only` on the changed implementation and new test: passed. - `python3 core/libs/tests/test_public_headers.py --audit-only`: passed (399 libraries, 26,227 exports). - `python3 tools/check_conventions.py --base origin/main`: zero errors; eight existing debt-length warnings in unrelated upstream files. `git diff --check`: passed. Original pre-rebase overlap check: ran `python3 tools/pr_overlap.py --branch codex/curl-lists-url-escaping --repo boykopovar/AnyPS5 --jobs 8` against 1,666 open PR heads. No shared exports. It reports textual overlap with #14337 at `Export.cpp:3` and `docs/dev/debt/libcurl.md:5`; merge ordering is declared above. The checker exits 2 because 12 existing PR branches conflict with main and share `core/libs/CMakeLists.txt`. I manually compared every flagged branch's diff from its merge base: #5021 changes macOS linker/rpath setup; #7275 adds render_override tests; #8650 adds VR tracker tests; #9156 adds pthread attribute tests; #9162 adds wait3/wait4 tests; #9293/#9297/#9302 add semaphore/message queue tests; #9383 adds rtld_printf tests; #12642 adds pthread suspend tests; #13253 adds dup tests; #13256 adds nanosleep tests. None touches the insertion before `guest_vorbis_dec_tests`, the curl target, or these curl exports. Not tested: Windows/macOS execution, any console comparison, strings larger than `INT_MAX`, or the full repository test suite. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none <!-- #14337 merged --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-11-01 13:45:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T13:45:46Z.

Review: COMMENTED


Reviewed — no blocking findings

The libcurl helpers are sound on the paths I read at head 71fc1c3f22376233ade2ce69215741677e504158; the new commit removes only test assertions for null-string behaviour, so the implementation is unchanged, but that behaviour is now untested.

What I ran

  • Exact head 71fc1c3f22376233ade2ce69215741677e504158 (one commit after the earlier head be4515f708), base 4768f0aeca680477597b2e42cba60ae49e48802c.
  • Environment: Linux, /usr/bin/python3 3.11.2, no build.
  • Precheck at the new head: python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14429 --output-dir /dev/shm/reviewer-run/precheck/14429b
  • Delta read with the compare API (be4515f7...71fc1c3f): one file, core/libs/tests/GuestCurl.cpp, 22 lines removed, no other file changed.
  • ABI audit by hand, against the local repository (the helper is absent from the head tree):
    python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 4768f0aeca680477597b2e42cba60ae49e48802c --head 71fc1c3f22376233ade2ce69215741677e504158 --json (exit 0; status passed; 0 findings; 85 symbols)
  • Test-quality helper by hand on core/libs/tests/GuestCurl.cpp from a head extract: one literal-path registration heuristic; the registration is at core/libs/CMakeLists.txt lines 1253-1262.

Results

Precheck report, checks table, unedited (/dev/shm/reviewer-run/precheck/14429b/report.md):

Check Status Command / reason
build_and_compile not_applicable The precheck deliberately does not configure, build, or compile AnyPS5.
diff_check passed git diff --check 4768f0aeca680477597b2e42cba60ae49e48802c...71fc1c3f22376233ade2ce69215741677e504158
conventions_and_pr_template passed /usr/bin/python3 tools/check_conventions.py --base 4768f0aeca680477597b2e42cba60ae49e48802c --head 71fc1c3f22376233ade2ce69215741677e504158 --title feat(libcurl): implement string lists and URL escaping --body /dev/shm/reviewer-run/precheck/14429b/pr-body.md
changed_export_abi_audit failed /usr/bin/python3 tools/pr_abi_audit.py --base 4768f0aeca680477597b2e42cba60ae49e48802c --head 71fc1c3f22376233ade2ce69215741677e504158 --json
python_syntax not_applicable No changed Python implementation files.
related_python_unit_tests not_applicable No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.
python_test_registration not_applicable No changed test_*.py files.
live_dependency_and_mergeability_check passed /usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14429 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14429b/stack
build_dependent_cpp_tests not_applicable Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.
test_quality_heuristics failed /usr/bin/python3 /dev/shm/reviewer-run/precheck/14429b/head-71fc1c3f2237-be3c0b1f/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14429b/head-71fc1c3f2237-be3c0b1f --json core/libs/CMakeLists.txt core/libs/prx/libcurl/Export.cpp core/libs/prx/libcurl/include/Api.hpp core/libs/prx/libcurl/include/InventoryExports.hpp core/libs/prx/libcurl/libcurl.hpp core/libs/tests/GuestCurl.cpp docs/dev/debt/libcurl.md
negative_controls not_applicable No changed Python test module in tools/ can be run as a no-build base-source control.

Negative control

Not run. The PR's earlier negative controls (lowercase escaping and a second-allocation leak) are the author's report, from temporary copies.

Findings

Blocking: none.

Non-blocking:

  • The removed block asserted that curl_easy_escape, curl_escape, curl_easy_unescape and curl_unescape throw for a null string with length 0 and 1, and that curl_slist_append(nullptr, nullptr) throws. Export.cpp still throws through NotImplemented_nid_no_patch for those inputs, so behaviour is unchanged, but nothing tests it at head. The PR body's Tested list still describes unsupported null strings as covered; that is stale. Either restore a test for the throw or update the body.

Sources

Not verified

  • The guest test guest_curl was not built or run here. The author's Release, ASan and UBSan results are for the earlier head.
  • The differential probe against curl 8.5.0 is the author's report; I did not rerun it.
  • The curl 8.10.1 escape.c citation was not matched: a grep of lib/escape.c at tag curl-8_10_1 for the unreserved set returned no match.
  • Console behaviour of these exports is unverified, as the PR states.
  • Hosted: at review time conventions was cancelled at this head, and eligibility, labels, library-portability and report were queued.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5728351792 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14429#pullrequestreview-5728351792). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T13:45:46Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The libcurl helpers are sound on the paths I read at head 71fc1c3f22376233ade2ce69215741677e504158; the new commit removes only test assertions for null-string behaviour, so the implementation is unchanged, but that behaviour is now untested. ## What I ran - Exact head `71fc1c3f22376233ade2ce69215741677e504158` (one commit after the earlier head `be4515f708`), base `4768f0aeca680477597b2e42cba60ae49e48802c`. - Environment: Linux, `/usr/bin/python3` 3.11.2, no build. - Precheck at the new head: `python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 14429 --output-dir /dev/shm/reviewer-run/precheck/14429b` - Delta read with the compare API (`be4515f7...71fc1c3f`): one file, `core/libs/tests/GuestCurl.cpp`, 22 lines removed, no other file changed. - ABI audit by hand, against the local repository (the helper is absent from the head tree): `python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 4768f0aeca680477597b2e42cba60ae49e48802c --head 71fc1c3f22376233ade2ce69215741677e504158 --json` (exit 0; status `passed`; 0 findings; 85 symbols) - Test-quality helper by hand on `core/libs/tests/GuestCurl.cpp` from a head extract: one literal-path registration heuristic; the registration is at `core/libs/CMakeLists.txt` lines 1253-1262. ## Results Precheck report, checks table, unedited (`/dev/shm/reviewer-run/precheck/14429b/report.md`): | Check | Status | Command / reason | |---|---|---| | build_and_compile | not_applicable | `The precheck deliberately does not configure, build, or compile AnyPS5.` | | diff_check | passed | `git diff --check 4768f0aeca680477597b2e42cba60ae49e48802c...71fc1c3f22376233ade2ce69215741677e504158` | | conventions_and_pr_template | passed | `/usr/bin/python3 tools/check_conventions.py --base 4768f0aeca680477597b2e42cba60ae49e48802c --head 71fc1c3f22376233ade2ce69215741677e504158 --title feat(libcurl): implement string lists and URL escaping --body /dev/shm/reviewer-run/precheck/14429b/pr-body.md` | | changed_export_abi_audit | failed | `/usr/bin/python3 tools/pr_abi_audit.py --base 4768f0aeca680477597b2e42cba60ae49e48802c --head 71fc1c3f22376233ade2ce69215741677e504158 --json` | | python_syntax | not_applicable | `No changed Python implementation files.` | | related_python_unit_tests | not_applicable | `No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.` | | python_test_registration | not_applicable | `No changed test_*.py files.` | | live_dependency_and_mergeability_check | passed | `/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 14429 --repo boykopovar/AnyPS5 --output-dir /dev/shm/reviewer-run/precheck/14429b/stack` | | build_dependent_cpp_tests | not_applicable | `Not run: C++ tests need exact-head binaries, which require a build; the precheck does not build.` | | test_quality_heuristics | failed | `/usr/bin/python3 /dev/shm/reviewer-run/precheck/14429b/head-71fc1c3f2237-be3c0b1f/tools/pr_test_quality.py --root /dev/shm/reviewer-run/precheck/14429b/head-71fc1c3f2237-be3c0b1f --json core/libs/CMakeLists.txt core/libs/prx/libcurl/Export.cpp core/libs/prx/libcurl/include/Api.hpp core/libs/prx/libcurl/include/InventoryExports.hpp core/libs/prx/libcurl/libcurl.hpp core/libs/tests/GuestCurl.cpp docs/dev/debt/libcurl.md` | | negative_controls | not_applicable | `No changed Python test module in tools/ can be run as a no-build base-source control.` | ## Negative control Not run. The PR's earlier negative controls (lowercase escaping and a second-allocation leak) are the author's report, from temporary copies. ## Findings **Blocking:** none. **Non-blocking:** - The removed block asserted that `curl_easy_escape`, `curl_escape`, `curl_easy_unescape` and `curl_unescape` throw for a null string with length 0 and 1, and that `curl_slist_append(nullptr, nullptr)` throws. `Export.cpp` still throws through `NotImplemented_nid_no_patch` for those inputs, so behaviour is unchanged, but nothing tests it at head. The PR body's Tested list still describes unsupported null strings as covered; that is stale. Either restore a test for the throw or update the body. ## Sources - Export implementation at head (unchanged by this delta): https://github.com/boykopovar/AnyPS5/blob/71fc1c3f22376233ade2ce69215741677e504158/core/libs/prx/libcurl/Export.cpp - Registration at head: https://github.com/boykopovar/AnyPS5/blob/71fc1c3f22376233ade2ce69215741677e504158/core/libs/CMakeLists.txt#L1253-L1262 ## Not verified - The guest test `guest_curl` was not built or run here. The author's Release, ASan and UBSan results are for the earlier head. - The differential probe against curl 8.5.0 is the author's report; I did not rerun it. - The curl 8.10.1 `escape.c` citation was not matched: a grep of `lib/escape.c` at tag `curl-8_10_1` for the unreserved set returned no match. - Console behaviour of these exports is unverified, as the PR states. - Hosted: at review time `conventions` was cancelled at this head, and `eligibility`, `labels`, `library-portability` and `report` were queued.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!14429
No description provided.