[php-src] Issue #23423: php_embed_ub_write does not return on error
| From: | Sjord | Date: | Sun, 23 Aug 2026 19:31:01 +0000 |
| Subject: | [php-src] Issue #23423: php_embed_ub_write does not return on error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-252653@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/23423
Author: Sjord
### Description
sapi/embed/php_embed.c:
```
/* SAPIs only have unbuffered write operations. This is because PHP's output
* buffering feature will handle any buffering of the output and invoke the
* SAPI unbuffered write operation when it flushes the buffer.
*/
static size_t php_embed_ub_write(const char *str, size_t str_length)
{
const char *ptr = str;
size_t remaining = str_length;
size_t ret;
while (remaining > 0) {
ret = php_embed_single_write(ptr, remaining);
if (!ret) {
php_handle_aborted_connection();
}
ptr += ret;
remaining -= ret;
}
return str_length;
}
```
php_handle_aborted_connection does not always abort, i.e. if
ignore_user_abort=1. So I sending fails and ret is 0, then
remaining is never decremented and this loops forever.
It should probably return str_length - remaining after
php_handle_aborted_connection().
### PHP Version
```plain
master
```
### Operating System
_No response_