[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Ilia Alshanetsky | Date: | Wed, 30 Sep 2026 12:10:54 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141769@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-09-30T08:06:54-04:00
Commit: https://github.com/php/php-src/commit/31db39c96b3712be24b42583af273c0c73ebfe2b
Raw diff: https://github.com/php/php-src/commit/31db39c96b3712be24b42583af273c0c73ebfe2b.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
sapi/cli: Fix built-in server truncating responses after a partial write
Changed paths:
M NEWS
M sapi/cli/php_cli_server.c
Diff:
diff --git a/NEWS b/NEWS
index 6e325f3df810..9a8bf446cf46 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ PHP NEWS
. Fixed BcMath\Number results that truncate to zero keeping a negative sign
and comparing less than zero. (Ilia Alshanetsky)
+- CLI:
+ . Fixed the built-in server truncating an error page and leaking its
+ unsent part after a partial socket write. (Ilia Alshanetsky)
+
- Core:
. Fixed OSS-Fuzz #536440507 (Immutable class incorrect assertion).
(ndossche)
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index e84348c95b4d..c9ed8ff53c63 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -1050,7 +1050,8 @@ static void php_cli_server_content_sender_ctor(php_cli_server_content_sender
*se
static int php_cli_server_content_sender_send(php_cli_server_content_sender *sender, php_socket_t
fd, size_t *nbytes_sent_total) /* {{{ */
{
php_cli_server_chunk *chunk, *next;
- size_t _nbytes_sent_total = 0;
+
+ *nbytes_sent_total = 0;
for (chunk = sender->buffer.first; chunk; chunk = next) {
#ifdef PHP_WIN32
@@ -1068,7 +1069,6 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender
*sen
nbytes_sent = send(fd, chunk->data.heap.p, chunk->data.heap.len, 0);
#endif
if (nbytes_sent < 0) {
- *nbytes_sent_total = _nbytes_sent_total;
return php_socket_errno();
#ifdef PHP_WIN32
} else if (nbytes_sent == chunk->data.heap.len) {
@@ -1084,8 +1084,10 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender
*sen
} else {
chunk->data.heap.p += nbytes_sent;
chunk->data.heap.len -= nbytes_sent;
+ *nbytes_sent_total += nbytes_sent;
+ return 0;
}
- _nbytes_sent_total += nbytes_sent;
+ *nbytes_sent_total += nbytes_sent;
break;
case PHP_CLI_SERVER_CHUNK_IMMORTAL:
@@ -1095,7 +1097,6 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender
*sen
nbytes_sent = send(fd, chunk->data.immortal.p, chunk->data.immortal.len, 0);
#endif
if (nbytes_sent < 0) {
- *nbytes_sent_total = _nbytes_sent_total;
return php_socket_errno();
#ifdef PHP_WIN32
} else if (nbytes_sent == chunk->data.immortal.len) {
@@ -1111,12 +1112,13 @@ static int php_cli_server_content_sender_send(php_cli_server_content_sender
*sen
} else {
chunk->data.immortal.p += nbytes_sent;
chunk->data.immortal.len -= nbytes_sent;
+ *nbytes_sent_total += nbytes_sent;
+ return 0;
}
- _nbytes_sent_total += nbytes_sent;
+ *nbytes_sent_total += nbytes_sent;
break;
}
}
- *nbytes_sent_total = _nbytes_sent_total;
return 0;
} /* }}} */