sapi/cli: check php_cli_server_client_send_through() return value - #23428
Open
lazerg wants to merge 2 commits into
Open
sapi/cli: check php_cli_server_client_send_through() return value#23428lazerg wants to merge 2 commits into
lazerg wants to merge 2 commits into
Conversation
lazerg
force-pushed
the
fix/issue-23425-cli-server-send-headers
branch
from
August 23, 2026 21:01
16edc5e to
fbf3fbe
Compare
devnexen
reviewed
Aug 23, 2026
|
|
||
| php_cli_server_client_send_through(client, ZSTR_VAL(buffer.s), ZSTR_LEN(buffer.s)); | ||
| size_t buffer_len = ZSTR_LEN(buffer.s); | ||
| bool sent = php_cli_server_client_send_through(client, ZSTR_VAL(buffer.s), buffer_len) == buffer_len; |
Member
There was a problem hiding this comment.
note that php_cli_server_client_send_through returns the number of bytes left on failure so it s wrong here if nothing was consumed.
Contributor
Author
There was a problem hiding this comment.
Good catch. On failure the callee returned nbytes_left, which equals str_len when nothing was sent, same value as success. Fixed in e2f8bcd: it now returns bytes actually sent (str_len - nbytes_left) on both paths, so this comparison is unambiguous.
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.
sapi_cli_server_send_headers() sends the header buffer through php_cli_server_client_send_through() but drops the return value, so it always reports SAPI_HEADER_SENT_SUCCESSFULLY, even when the send fails and php_handle_aborted_connection() doesn't bail out (ignore_user_abort=1). This compares the send result against the buffer length and returns SAPI_HEADER_SEND_FAILED when it comes up short.
Fixes #23425