[php-src] PR #15183: Fix GH-15181: Disabled output handler is flushed again
| From: | cmb69 | Date: | Wed, 31 Jul 2024 20:05:53 +0000 |
| Subject: | [php-src] PR #15183: Fix GH-15181: Disabled output handler is flushed again | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-27587@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/15183
Author: cmb69
When an
PHP_OUTPUT_HANDLER_FAILURE occurs, the output handler becomes disabled (i.e.
the PHP_OUTPUT_HANDLER_DISABLED flag is set). However, there is no guard for disabled
handlers in php_output_handler_op() what may cause serious issues (as reported, UB due
to passing NULL as the 2nd argument of memcpy, because the handler's
buffer has already been NULLed). Therefore, we add a respective guard for disabled
handlers, and return PHP_OUTPUT_HANDLER_FAILURE right away.
---
Note that older PHP versions are affected by this (confirmed with PHP-8.3, but might be a
long-standing issue), and although the behavior is obviously a bug, I'm still reluctant to
deploy the fix to lower branches, given the complexities of PHP's output handling, and certain
user expectations. For the given test scripts, unpatched PHP-8.3/master would output the fatal
error and the respective stack backtrace.