Commit 8190d749c70 for php
commit 8190d749c700461cfc0b984b48ca59e06d63157b
Merge: f1c7f2d4f73 feaa8a10a18
Author: David Carlier <devnexen@gmail.com>
Date: Fri Nov 20 20:42:58 2026 +0000
Merge branch 'PHP-8.6'
* PHP-8.6:
streams: UAF in php_stream_cast() when stream_flush() closes the stream
diff --cc main/streams/userspace.c
index 77047585bea,ec8bdcdf0ac..088eb21bfda
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@@ -742,10 -737,16 +742,16 @@@ static int php_userstreamop_flush(php_s
assert(us != NULL);
+ uint32_t orig_no_fclose = stream->flags & PHP_STREAM_FLAG_NO_FCLOSE;
+ stream->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
+
zend_string *func_name = ZSTR_INIT_LITERAL(USERSTREAM_FLUSH, false);
- zend_result call_result = zend_call_method_if_exists(Z_OBJ(us->object), func_name, &retval, 0, NULL);
+ zend_result call_result = zend_call_method_if_exists(us->object, func_name, &retval, 0, NULL);
zend_string_release_ex(func_name, false);
+ stream->flags &= ~PHP_STREAM_FLAG_NO_FCLOSE;
+ stream->flags |= orig_no_fclose;
+
int ret = call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zend_is_true(&retval) ? 0 : -1;
zval_ptr_dtor(&retval);