Repository navigation
Conversation
PARSING_HEADER() excluded the F_TRAILING state, so bytes of chunked request trailers were never counted against PHP_HTTP_MAX_HEADER_SIZE. Count them like regular headers, as done upstream in nodejs/http-parser 81ca70aec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
devnexen
reviewed
Oct 30, 2026
| @@ -0,0 +1,38 @@ | |||
| --TEST-- | |||
Member
There was a problem hiding this comment.
--- a/sapi/cli/tests/gh24115.phpt
+++ b/sapi/cli/tests/gh24115.phpt
@@ -14,7 +14,7 @@ $head = "POST / HTTP/1.1\r\nHost: $host\r\nTransfer-Encoding: chunked\r\nConnect
function send(string $request): string {
$fp = php_cli_server_connect();
- fwrite($fp, $request);
+ @fwrite($fp, $request);
$response = stream_get_contents($fp);
fclose($fp);
return $response;
@@ -26,7 +26,7 @@ echo "small trailer: ", str_contains($response, "200 OK") ? "200" : "FAIL", "\n"
// A trailer larger than the header size limit is rejected.
$response = send($head . "0\r\nX-Fill: " . str_repeat("A", 100 * 1024) . "\r\n\r\n");
-echo "oversized trailer: ", str_contains($response, "200 OK") ? "FAIL" : "rejected", "\n";
+echo "oversized trailer: ", $response === '' ? "rejected" : "FAIL", "\n";
// The server keeps serving requests afterwards.
$response = send($head . "0\r\n\r\n");
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes GH-24115.
PARSING_HEADER()insapi/cli/php_http_parser.cexcluded theF_TRAILINGstate, so the bytes of chunked request trailers were never counted innread, andPHP_HTTP_MAX_HEADER_SIZEdid not apply to them. A client could send an unbounded trailer section after the0\r\nchunk.The fix drops the
F_TRAILINGexception, so trailers are counted like regular headers. This is the same change upstream nodejs/http-parser made in 81ca70aec ("Avoid chunk trailer overflow").Notes:
nreadis reset at the end of the regular headers, so trailers get their own 80 KB budget. Chunk sizes and chunk data are not counted.nreadis not reset beforeNEW_MESSAGE(). This does not matter today because the CLI server always replies withConnection: close. I can add a reset there if you prefer.Test:
sapi/cli/tests/gh24115.phptsends a small trailer (200), a 100 KB trailer (rejected), and then checks that the server still answers. The test fails without the fix. I also ran a short randomized check with chunked bodies up to 200 KB and trailers up to 160 KB, and every response matched the limit.🤖 Generated with Claude Code