fix(http2): validate and decode concatenated gzip members #15231

Merged
JJenkx merged 2 commits from upstream-pr/15231 into main 2026-11-05 04:27:55 +00:00
JJenkx commented 2026-11-02 21:25:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-02T21:25:35Z.


What

Valid concatenated gzip members currently throw, and optional FHCRC bytes are skipped without checking them. Iterate the existing gzip framing parser, reset raw inflate between members, verify each member's CRC32/ISIZE, and check FHCRC over that member's header. Empty members and combined decoded lengths work; the existing 64 MiB combined decoded limit stays in force.

Current head 939d961c50fa6b28d514b2d1ea19441841a6b8eb includes pinned main b11c7bf84f5d2f636ff60166cc3371bd071e24d5 and preserves the reviewed gzip decoder from 3989a014e7. No pending HTTP prerequisites. The vendored zconf.h disables built-in gzip wrapping, so this retains the bounded explicit parser and existing raw zlib backend. No new dependency or third-party changes.

Format semantics: RFC1952 member structure and integrity. Console buffering, length/header reporting, size limits and error mappings remain unverified in debt; this is protocol correctness, not a console-parity claim.

The original overlap audit checked1,716 open heads. Shared fixtures/debt touch #11611, #11630, #11922, #11950, #12305, #12456 and our #15221; no other implementation of this member/FHCRC behavior was found. #11470/#13486/#14212 have incomplete comparisons because they conflict with the base. Our #15221 includes this actual refreshed head at e064f99e62ce1e4ab25ddc3adcccd254c4133e95 and remains ordered after it. Its fresh Linux qualification is recorded there. This pure-main branch does not require the HTTP/1 prerequisite stack.

Tested

Latest qualification (2026-11-04): exact head 939d961c50fa6b28d514b2d1ea19441841a6b8eb, tested main b11c7bf84f5d2f636ff60166cc3371bd071e24d5. Production outside InflateGzip is byte-identical to main; the decoder is byte-identical to old reviewed head 3989a014e7. The shared fixture preserves main's HTTP/1, TLS-handshake, SSL-callback, redirect and early-response coverage, with enum order retained.

Linux x86_64, GCC 16.2.1, Release, CPU-only loopback: 13/13 passed, zero skips (12 HTTP2 groups plus public headers). The actual raw production module and fixtures rebuilt; production NID patching, conventions, whitespace, and MinGW syntax for Export.cpp/Transport.cpp passed. With only main's Transport.cpp substituted, both member/header groups fail at the expected concatenated-member/header-checksum checks. Restoring this head passes both groups and reproduces the exact source, fixture-executable and shared-library hashes.

Commands, preservation proofs, logs, JUnit and hashes. No new Windows/macOS runtime, console, title, GPU or performance claim. Earlier qualifications below retain their original pins.

Linux7.2.11 Arch, Ryzen 9 7950X, GCC16.2.1, Release; CPU-only loopback.

  • All10 guest_http2* groups plus public_headers:11/11, zero skips.
  • Frozen final executable fails both focused tests with only main's Transport.cpp substituted: concatenation rejects valid input, bad FHCRC is accepted. Restore the exact candidate source/library and both groups pass3/3, with unchanged executable and restored library hashes.
  • Inflation on/off, read-first/length-first, partial/zero reads, repeated EOF, empty members,70,000-byte plus tail, optional fields on consecutive members, first/later header CRC, later data CRC/ISIZE, trailing invalid data; existing single-member tests pass.
  • Windows GCC15.2 UCRT r7 Release CI checked out main 9090972b7e91 and merged this exact head. All11 registered guest_http2* groups passed, including _gzip_members (0.35s) and _gzip_headers (0.13s). Windows CI log. The overall job is failed: guest_avplayer_http, avplayer_http_transport, avplayer_http_patched_modules and guest_http_client timed out. Windows worker follow-up on unchanged main 5cb015caaaa and main plus this exact head: the same four tests pass serially3/3 on each side (24 executions, zero failures/skips; JUnit independently checked). Control evidence, SHA256 88eb6e24fd4e7886754df181fdc97a2b2818d921adfd9d3a51d881100ead9f98. These controls did not reproduce the timeouts; the original CI failure remains unresolved, with no timeout or production change claimed.
  • Conventions and whitespace pass. Native titles not tested. No speed claim.

Source, full logs, JUnit, compile commands, loader bindings, hashes and control procedure, SHA256 93219cc26580343f1ae8cd51ddc05f0512ab82849b200baaf7a797e0a4388f92.

Independent current-head AMD follow-up: TechLevelZero report, exact 2845d2c1c078 merged onto 7feb37ee3e30, RX6300/RADV Mesa25.2.8. The selected 1,134 tests produced1,122 passes,5 failures (3 also fail on main and2 unstable on main),7 skips, and no new validation IDs across539 GPU tests. This is attributed third-party evidence, not an all-green full-suite result. The separate upstream Windows timeout job remains unresolved; local main/PR controls and the maintainer rerun request above do not change that CI status.

Independent Windows review by BunnyFl covers exact head 3989a014e7 merged onto main (merge a9c7022d50): Windows 11, WinLibs GCC, Release. All twelve HTTP2 groups pass; restoring only main’s Transport.cpp while retaining this head’s tests fails exactly gzip member/header validation, while the other ten groups pass. These are the reviewer’s reported runs; the report does not specify the compiler version or host CPU. No source change or new author-run Windows test accompanies this attribution.

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; generic gzip format completion
  • GPUs tested: n/a
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5127673788 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15231). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-11-02T21:25:35Z. --- ### What Valid concatenated gzip members currently throw, and optional FHCRC bytes are skipped without checking them. Iterate the existing gzip framing parser, reset raw inflate between members, verify each member's CRC32/ISIZE, and check FHCRC over that member's header. Empty members and combined decoded lengths work; the existing 64 MiB combined decoded limit stays in force. Current head `939d961c50fa6b28d514b2d1ea19441841a6b8eb` includes pinned main `b11c7bf84f5d2f636ff60166cc3371bd071e24d5` and preserves the reviewed gzip decoder from `3989a014e7`. No pending HTTP prerequisites. The vendored [zconf.h](https://github.com/libjpeg-turbo/libjpeg-turbo/blob/c85e6b905bf237038faa936dab160ebfc5da0344/src/spng/zlib/zconf.h#L14) disables built-in gzip wrapping, so this retains the bounded explicit parser and existing raw zlib backend. No new dependency or third-party changes. Format semantics: [RFC1952 member structure and integrity](https://www.rfc-editor.org/rfc/rfc1952). Console buffering, length/header reporting, size limits and error mappings remain unverified in debt; this is protocol correctness, not a console-parity claim. The original overlap audit checked1,716 open heads. Shared fixtures/debt touch #11611, #11630, #11922, #11950, #12305, #12456 and our #15221; no other implementation of this member/FHCRC behavior was found. #11470/#13486/#14212 have incomplete comparisons because they conflict with the base. Our #15221 includes this actual refreshed head at `e064f99e62ce1e4ab25ddc3adcccd254c4133e95` and remains ordered after it. Its fresh Linux qualification is recorded there. This pure-main branch does not require the HTTP/1 prerequisite stack. ### Tested Latest qualification (2026-11-04): exact head `939d961c50fa6b28d514b2d1ea19441841a6b8eb`, tested main `b11c7bf84f5d2f636ff60166cc3371bd071e24d5`. Production outside `InflateGzip` is byte-identical to main; the decoder is byte-identical to old reviewed head `3989a014e7`. The shared fixture preserves main's HTTP/1, TLS-handshake, SSL-callback, redirect and early-response coverage, with enum order retained. Linux x86_64, GCC 16.2.1, Release, CPU-only loopback: **13/13 passed**, zero skips (12 HTTP2 groups plus public headers). The actual raw production module and fixtures rebuilt; production NID patching, conventions, whitespace, and MinGW syntax for Export.cpp/Transport.cpp passed. With only main's Transport.cpp substituted, both member/header groups fail at the expected concatenated-member/header-checksum checks. Restoring this head passes both groups and reproduces the exact source, fixture-executable and shared-library hashes. [Commands, preservation proofs, logs, JUnit and hashes](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/http-gzip-mainb11c-linux-20261104-terminal.tar.gz). No new Windows/macOS runtime, console, title, GPU or performance claim. Earlier qualifications below retain their original pins. Linux7.2.11 Arch, Ryzen 9 7950X, GCC16.2.1, Release; CPU-only loopback. - All10 `guest_http2*` groups plus `public_headers`:11/11, zero skips. - Frozen final executable fails both focused tests with only main's Transport.cpp substituted: concatenation rejects valid input, bad FHCRC is accepted. Restore the exact candidate source/library and both groups pass3/3, with unchanged executable and restored library hashes. - Inflation on/off, read-first/length-first, partial/zero reads, repeated EOF, empty members,70,000-byte plus tail, optional fields on consecutive members, first/later header CRC, later data CRC/ISIZE, trailing invalid data; existing single-member tests pass. - Windows GCC15.2 UCRT r7 Release CI checked out main `9090972b7e91` and merged this exact head. All11 registered `guest_http2*` groups passed, including `_gzip_members` (0.35s) and `_gzip_headers` (0.13s). [Windows CI log](https://github.com/boykopovar/AnyPS5/actions/runs/41528233711/job/125561707133). The overall job is **failed**: `guest_avplayer_http`, `avplayer_http_transport`, `avplayer_http_patched_modules` and `guest_http_client` timed out. Windows worker follow-up on unchanged main `5cb015caaaa` and main plus this exact head: the same four tests pass serially3/3 on each side (24 executions, zero failures/skips; JUnit independently checked). [Control evidence](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/http-timeout-15231-windows-controls-20261102.tar.gz), SHA256 `88eb6e24fd4e7886754df181fdc97a2b2818d921adfd9d3a51d881100ead9f98`. These controls did not reproduce the timeouts; the original CI failure remains unresolved, with no timeout or production change claimed. - Conventions and whitespace pass. Native titles not tested. No speed claim. [Source, full logs, JUnit, compile commands, loader bindings, hashes and control procedure](https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/http2-gzip-members-main909-linux-20261102.tar.gz), SHA256 `93219cc26580343f1ae8cd51ddc05f0512ab82849b200baaf7a797e0a4388f92`. Independent current-head AMD follow-up: [TechLevelZero report](https://github.com/boykopovar/AnyPS5/pull/15231#issuecomment-6594565601), exact `2845d2c1c078` merged onto `7feb37ee3e30`, RX6300/RADV Mesa25.2.8. The selected 1,134 tests produced1,122 passes,5 failures (3 also fail on main and2 unstable on main),7 skips, and no new validation IDs across539 GPU tests. This is attributed third-party evidence, not an all-green full-suite result. The separate upstream Windows timeout job remains unresolved; local main/PR controls and the maintainer rerun request above do not change that CI status. <!-- 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. --> Independent [Windows review by BunnyFl](https://github.com/boykopovar/AnyPS5/pull/15231#pullrequestreview-5760971807) covers exact head `3989a014e7` merged onto main (merge `a9c7022d50`): Windows 11, WinLibs GCC, Release. All twelve HTTP2 groups pass; restoring only main’s Transport.cpp while retaining this head’s tests fails exactly gzip member/header validation, while the other ten groups pass. These are the reviewer’s reported runs; the report does not specify the compiler version or host CPU. No source change or new author-run Windows test accompanies this attribution. ### 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; generic gzip format completion - [x] GPUs tested: n/a - [x] AI-assisted: yes (Codex)
BunnyFl commented 2026-11-03 23:31:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T23:31:05Z.

Review: APPROVED


@JJenkx approved at 3989a014e7.

What I ran: this head merged onto main (merge a9c7022d50), Windows 11, WinLibs GCC, Release.

  • All 12 guest_http2* tests pass (12 of 12), including guest_http2_gzip_members and guest_http2_gzip_headers.
  • With main's core/libs/prx/libSceHttp2/Transport.cpp put back and this branch's tests kept, exactly those two fail (2 of 12 failed). The other ten still pass.

Read in InflateGzip, per member:

  • The magic, method and reserved-flag checks run on each member's own header (size - offset >= 18), not only the first.
  • FHCRC is compared with the low 16 bits of the CRC32 over that member's header bytes, up to the CRC16 itself. That is RFC 1952 §2.3.1.
  • inflate is given everything from the member's data to the end of the body. After Z_STREAM_END, offset = size - inflater.avail_in lands on the member's trailer. CRC32 and ISIZE are checked over that member's slice of output, and an empty member's crc32(0, nullptr, 0) is 0, as it should be.
  • inflateReset runs only when another member follows.
  • Bounds:
    • skip now checks offset <= size - 8 && count <= size - 8 - offset (Transport.cpp:406); neither subtraction can wrap.
    • The decoded limit is checked before insert (count <= MaxGzipBytes - output.size()).
    • The new encoded-size limit keeps the uInt casts of avail_in and the CRC lengths in range.

One behaviour worth knowing, and already in your tests: any bytes after the last member that aren't another gzip member now fail as malformed gzip header. gzip -d warns about trailing garbage and keeps the decoded data instead. Neither is a console measurement, and the debt entry already leaves console error mapping unverified, so throwing is fine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5760971807 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15231#pullrequestreview-5760971807). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-03T23:31:05Z. **Review:** APPROVED --- @JJenkx approved at `3989a014e7`. **What I ran:** this head merged onto `main` (merge `a9c7022d50`), Windows 11, WinLibs GCC, Release. - All 12 `guest_http2*` tests pass (12 of 12), including `guest_http2_gzip_members` and `guest_http2_gzip_headers`. - With `main`'s `core/libs/prx/libSceHttp2/Transport.cpp` put back and this branch's tests kept, exactly those two fail (2 of 12 failed). The other ten still pass. **Read in `InflateGzip`, per member:** - The magic, method and reserved-flag checks run on each member's own header (`size - offset >= 18`), not only the first. - FHCRC is compared with the low 16 bits of the CRC32 over that member's header bytes, up to the CRC16 itself. That is RFC 1952 §2.3.1. - `inflate` is given everything from the member's data to the end of the body. After `Z_STREAM_END`, `offset = size - inflater.avail_in` lands on the member's trailer. CRC32 and ISIZE are checked over that member's slice of `output`, and an empty member's `crc32(0, nullptr, 0)` is 0, as it should be. - `inflateReset` runs only when another member follows. - **Bounds:** - `skip` now checks `offset <= size - 8 && count <= size - 8 - offset` (`Transport.cpp:406`); neither subtraction can wrap. - The decoded limit is checked before `insert` (`count <= MaxGzipBytes - output.size()`). - The new encoded-size limit keeps the `uInt` casts of `avail_in` and the CRC lengths in range. One behaviour worth knowing, and already in your tests: any bytes after the last member that aren't another gzip member now fail as `malformed gzip header`. `gzip -d` warns about trailing garbage and keeps the decoded data instead. Neither is a console measurement, and the debt entry already leaves console error mapping unverified, so throwing is fine.
BunnyFl commented 2026-11-04 15:46:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T15:46:20Z.

Review: APPROVED


@JJenkx re-checked at 939d961c50. git range-diff of my approved 3989a014e7 against this head shows that commit unchanged; the rest is the merge of main b11c7bf84f.

What I ran: head 939d961c50 (it already contains main b11c7bf84f), Windows 11, WinLibs GCC, Release, BUILD_TESTING=ON:

  • guest_http2* and public_headers: 14 of 14 pass. That covers main's HTTP/1, TLS-handshake, SSL-callback, redirect and early-response groups next to yours.
  • Negative control: with main's core/libs/prx/libSceHttp2/Transport.cpp and the tests kept, guest_http2_gzip_members and guest_http2_gzip_headers abort. The other 12 pass.
  • Overlap, checked by merging: our own #11950 (cookie boxes, now with your HTTP/1.x commit) also edits core/libs/tests/GuestHttp2Transport.cpp. Merging the two onto main in either order conflicts in that test file only; Transport.cpp merges cleanly. If this lands first, I'll resolve it on #11950's side.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5771292023 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15231#pullrequestreview-5771292023). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-04T15:46:20Z. **Review:** APPROVED --- @JJenkx re-checked at `939d961c50`. `git range-diff` of my approved `3989a014e7` against this head shows that commit unchanged; the rest is the merge of `main` `b11c7bf84f`. **What I ran:** head `939d961c50` (it already contains `main` `b11c7bf84f`), Windows 11, WinLibs GCC, Release, `BUILD_TESTING=ON`: - `guest_http2*` and `public_headers`: 14 of 14 pass. That covers `main`'s HTTP/1, TLS-handshake, SSL-callback, redirect and early-response groups next to yours. - Negative control: with `main`'s `core/libs/prx/libSceHttp2/Transport.cpp` and the tests kept, `guest_http2_gzip_members` and `guest_http2_gzip_headers` abort. The other 12 pass. - Overlap, checked by merging: our own #11950 (cookie boxes, now with your HTTP/1.x commit) also edits `core/libs/tests/GuestHttp2Transport.cpp`. Merging the two onto `main` in either order conflicts in that test file only; `Transport.cpp` merges cleanly. If this lands first, I'll resolve it on #11950's side.
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!15231
No description provided.