fix(libSceHttp2): accept whitespace before chunk extensions #18378

Merged
Ondra97 merged 1 commit from upstream-pr/18378 into main 2026-11-12 12:03:59 +00:00
Ondra97 commented 2026-11-11 12:59:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-11-11T12:59:53Z.


What

An HTTP/1.1 response read through libSceHttp2 fails when a chunk size is followed by a space or tab before an extension delimiter, such as 8 ;test=yes. The complete prefix is passed to the strict numeric decoder, so sceHttp2ReadData throws instead of delivering a valid response.

Remove trailing SP and HTAB from the numeric prefix when a semicolon is present, then use the existing size decoder. This follows the BWS positions in RFC 9112 section 7.1.1. Other numeric parsing remains unchanged.

Tested

Windows 11 Pro 10.0.26300, AMD Ryzen 9 7900X, 32 GiB RAM, NVIDIA RTX 4070 Ti SUPER present but not exercised; WinLibs GCC 15.2.0 UCRT POSIX SEH r7, Release, full build configuration with BUILD_TESTING=ON.

Base: 2ecc68bda2642fbd5b4c9fb799bc1da4aa3df191. Tested head: e717e8630ec3d1cdbd722d1423e96e11a49f32db.

The regression uses the existing TLS loopback server and public HTTP2 calls, reads the exact response body and consumes EOF. It applies SP, HTAB and mixed SP/HTAB before an extension on the first data chunk, second data chunk and terminating zero chunk.

Metric Before (base) After (fix)
Valid chunk-whitespace responses read completely 0/9 9/9

On unchanged base code, every added case threw sceHttp2: invalid number; the regression failed. With the fix, all nine cases and the existing HTTP/1 controls, malformed-response checks and cancellation checks passed.

cmake --build ../build --target guest_http2_transport_tests --parallel 6
cmake -DDEST_DIR=../build/tests -P cmake/CopyRuntimeFiles.cmake ../build/core/libs/libs/unpatched/libSceHttp2.prx
ctest --test-dir ../build --output-on-failure -V -R '^(guest_http2_http1|guest_http2_http1_cookies|guest_http2_transport)$'
python tools/check_conventions.py --base origin/main
python tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch codex/fix-http2-chunk-whitespace --jobs 8

Three CTests passed, none skipped. Runtime modules were refreshed with the existing copy helper before testing; the staged HTTP2 module's hash matched the rebuilt module. Conventions passed. The overlap check found no overlap with the open PRs, including the five related HTTP2 patches. No title, Linux runtime or full repository test suite was run.

The hosted Windows job passed on this head merged into main 1e8dfd6: 11 CTests passed, none skipped, including guest_http2_http1.

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:5259913483 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18378). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-11-11T12:59:53Z. --- ### What An HTTP/1.1 response read through libSceHttp2 fails when a chunk size is followed by a space or tab before an extension delimiter, such as `8 ;test=yes`. The complete prefix is passed to the strict numeric decoder, so `sceHttp2ReadData` throws instead of delivering a valid response. Remove trailing SP and HTAB from the numeric prefix when a semicolon is present, then use the existing size decoder. This follows the BWS positions in [RFC 9112 section 7.1.1](https://www.rfc-editor.org/rfc/rfc9112.html#section-7.1.1). Other numeric parsing remains unchanged. ### 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. --> Windows 11 Pro 10.0.26300, AMD Ryzen 9 7900X, 32 GiB RAM, NVIDIA RTX 4070 Ti SUPER present but not exercised; WinLibs GCC 15.2.0 UCRT POSIX SEH r7, Release, full build configuration with `BUILD_TESTING=ON`. Base: `2ecc68bda2642fbd5b4c9fb799bc1da4aa3df191`. Tested head: `e717e8630ec3d1cdbd722d1423e96e11a49f32db`. The regression uses the existing TLS loopback server and public HTTP2 calls, reads the exact response body and consumes EOF. It applies SP, HTAB and mixed SP/HTAB before an extension on the first data chunk, second data chunk and terminating zero chunk. | Metric | Before (base) | After (fix) | |---|---:|---:| | Valid chunk-whitespace responses read completely | 0/9 | 9/9 | On unchanged base code, every added case threw `sceHttp2: invalid number`; the regression failed. With the fix, all nine cases and the existing HTTP/1 controls, malformed-response checks and cancellation checks passed. ```sh cmake --build ../build --target guest_http2_transport_tests --parallel 6 cmake -DDEST_DIR=../build/tests -P cmake/CopyRuntimeFiles.cmake ../build/core/libs/libs/unpatched/libSceHttp2.prx ctest --test-dir ../build --output-on-failure -V -R '^(guest_http2_http1|guest_http2_http1_cookies|guest_http2_transport)$' python tools/check_conventions.py --base origin/main python tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch codex/fix-http2-chunk-whitespace --jobs 8 ``` Three CTests passed, none skipped. Runtime modules were refreshed with the existing copy helper before testing; the staged HTTP2 module's hash matched the rebuilt module. Conventions passed. The overlap check found no overlap with the open PRs, including the five related HTTP2 patches. No title, Linux runtime or full repository test suite was run. The [hosted Windows job](https://github.com/boykopovar/AnyPS5/actions/runs/43025151190/job/130538355635) passed on this head merged into main `1e8dfd6`: 11 CTests passed, none skipped, including `guest_http2_http1`. ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-11 14:57:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-11T14:57:27Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against e717e8630e:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_http2_transport_tests built cleanly.
  • CTest (guest_http2_gzip_members, guest_http2_gzip_headers, guest_http2_transport, guest_http2_early_response, guest_http2_system_roots, guest_http2_http1, guest_http2_http1_cookies, guest_http2_ssl_callbacks, guest_http2_redirects, guest_http2_auth_status):
    1/10 Test #3127: guest_http2_transport ............   Passed   10.50 sec
    2/10 Test #3133: guest_http2_redirects ............   Passed   15.66 sec
    3/10 Test #3130: guest_http2_http1 ................   Passed    9.12 sec
    4/10 Test #3125: guest_http2_gzip_members .........   Passed    4.96 sec
    5/10 Test #3132: guest_http2_ssl_callbacks ........   Passed    2.44 sec
    6/10 Test #3135: guest_http2_auth_status ..........   Passed    3.68 sec
    7/10 Test #3126: guest_http2_gzip_headers .........   Passed    0.99 sec
    8/10 Test #3128: guest_http2_early_response .......   Passed    0.94 sec
    9/10 Test #3129: guest_http2_system_roots .........   Passed    0.22 sec
    10/10 Test #3131: guest_http2_http1_cookies ........   Passed    0.74 sec
    100% tests passed, 0 tests failed out of 10
    
  • Negative control: with core/libs/prx/libSceHttp2/Transport.cpp reverted to main and the new tests kept, the suite fails:
    4/10 Test #3125: guest_http2_gzip_members .........   Passed    4.40 sec
    5/10 Test #3135: guest_http2_auth_status ..........   Passed    4.08 sec
    6/10 Test #3126: guest_http2_gzip_headers .........   Passed    2.22 sec
    7/10 Test #3132: guest_http2_ssl_callbacks ........   Passed    3.98 sec
    8/10 Test #3131: guest_http2_http1_cookies ........   Passed    0.80 sec
    9/10 Test #3128: guest_http2_early_response .......   Passed    1.06 sec
    10/10 Test #3129: guest_http2_system_roots .........   Passed    0.24 sec
    90% tests passed, 1 tests failed out of 10
    
    Restoring the change makes it pass again.
  • Code reading:
    • Verified in core/libs/prx/libSceHttp2/Transport.cpp that std::string_view::substr(0, extension) and digits.remove_suffix(1) guard against out-of-bounds access with !digits.empty(), correctly handling empty prefixes or lines starting with ';'.
    • Verified in core/libs/prx/libSceHttp2/Transport.cpp that Number(digits, 16) continues to strictly validate parsed hex digits via std::from_chars, routing empty or invalid inputs to Require and Unknown() (NotImplemented_nid_no_patch).
    • Verified in core/libs/prx/libSceHttp2/Transport.cpp that chunk sizes without semicolon delimiters are left intact so that trailing whitespace without extensions continues to be rejected per RFC 9112 Section 7.1 grammar.
    • Verified that no comments were added to core/libs/prx/libSceHttp2/Transport.cpp or core/libs/tests/GuestHttp2Transport.cpp in strict compliance with AGENTS.md conventions.
    • Verified that ResponseSpec in core/libs/tests/GuestHttp2Transport.cpp value-initializes chunkWhitespace to empty strings, guaranteeing byte-identical chunk streams for all existing Mode::Http11Chunked tests.
    • Verified that Http1ChunkWhitespace in core/libs/tests/GuestHttp2Transport.cpp exercises SP, HTAB, and mixed SP/HTAB paddings across first data chunks, subsequent data chunks, and terminating zero chunks with clean server joining and full test cleanup.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5860729979 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18378#pullrequestreview-5860729979). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-11T14:57:27Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `e717e8630e`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_http2_transport_tests` built cleanly. - **CTest** (`guest_http2_gzip_members`, `guest_http2_gzip_headers`, `guest_http2_transport`, `guest_http2_early_response`, `guest_http2_system_roots`, `guest_http2_http1`, `guest_http2_http1_cookies`, `guest_http2_ssl_callbacks`, `guest_http2_redirects`, `guest_http2_auth_status`): ``` 1/10 Test #3127: guest_http2_transport ............ Passed 10.50 sec 2/10 Test #3133: guest_http2_redirects ............ Passed 15.66 sec 3/10 Test #3130: guest_http2_http1 ................ Passed 9.12 sec 4/10 Test #3125: guest_http2_gzip_members ......... Passed 4.96 sec 5/10 Test #3132: guest_http2_ssl_callbacks ........ Passed 2.44 sec 6/10 Test #3135: guest_http2_auth_status .......... Passed 3.68 sec 7/10 Test #3126: guest_http2_gzip_headers ......... Passed 0.99 sec 8/10 Test #3128: guest_http2_early_response ....... Passed 0.94 sec 9/10 Test #3129: guest_http2_system_roots ......... Passed 0.22 sec 10/10 Test #3131: guest_http2_http1_cookies ........ Passed 0.74 sec 100% tests passed, 0 tests failed out of 10 ``` - **Negative control**: with `core/libs/prx/libSceHttp2/Transport.cpp` reverted to `main` and the new tests kept, the suite fails: ``` 4/10 Test #3125: guest_http2_gzip_members ......... Passed 4.40 sec 5/10 Test #3135: guest_http2_auth_status .......... Passed 4.08 sec 6/10 Test #3126: guest_http2_gzip_headers ......... Passed 2.22 sec 7/10 Test #3132: guest_http2_ssl_callbacks ........ Passed 3.98 sec 8/10 Test #3131: guest_http2_http1_cookies ........ Passed 0.80 sec 9/10 Test #3128: guest_http2_early_response ....... Passed 1.06 sec 10/10 Test #3129: guest_http2_system_roots ......... Passed 0.24 sec 90% tests passed, 1 tests failed out of 10 ``` Restoring the change makes it pass again. - **Code reading**: - Verified in core/libs/prx/libSceHttp2/Transport.cpp that std::string_view::substr(0, extension) and digits.remove_suffix(1) guard against out-of-bounds access with !digits.empty(), correctly handling empty prefixes or lines starting with ';'. - Verified in core/libs/prx/libSceHttp2/Transport.cpp that Number(digits, 16) continues to strictly validate parsed hex digits via std::from_chars, routing empty or invalid inputs to Require and Unknown() (NotImplemented_nid_no_patch). - Verified in core/libs/prx/libSceHttp2/Transport.cpp that chunk sizes without semicolon delimiters are left intact so that trailing whitespace without extensions continues to be rejected per RFC 9112 Section 7.1 grammar. - Verified that no comments were added to core/libs/prx/libSceHttp2/Transport.cpp or core/libs/tests/GuestHttp2Transport.cpp in strict compliance with AGENTS.md conventions. - Verified that ResponseSpec in core/libs/tests/GuestHttp2Transport.cpp value-initializes chunkWhitespace to empty strings, guaranteeing byte-identical chunk streams for all existing Mode::Http11Chunked tests. - Verified that Http1ChunkWhitespace in core/libs/tests/GuestHttp2Transport.cpp exercises SP, HTAB, and mixed SP/HTAB paddings across first data chunks, subsequent data chunks, and terminating zero chunks with clean server joining and full test cleanup. - Note: the AI-assisted checkbox can stay. Looks Good To Me
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!18378
No description provided.