mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix GH-8827: Intentionally closing std handles no longer possible
We revert the commits which caused this regression from the PHP-8.0 and PHP-8.1 branches for now. We keep it in "master" because of PR #8833 which may offer a proper fix without BC break.
This commit is contained in:
parent
6f87a5c633
commit
a8437d08a8
4 changed files with 9 additions and 28 deletions
3
NEWS
3
NEWS
|
@ -5,6 +5,9 @@ PHP NEWS
|
||||||
- Core:
|
- Core:
|
||||||
. Fixed potential use after free in php_binary_init(). (Heiko Weber)
|
. Fixed potential use after free in php_binary_init(). (Heiko Weber)
|
||||||
|
|
||||||
|
- CLI:
|
||||||
|
. Fixed GH-8827 (Intentionally closing std handles no longer possible). (cmb)
|
||||||
|
|
||||||
- COM:
|
- COM:
|
||||||
. Fixed bug GH-8778 (Integer arithmethic with large number variants fails).
|
. Fixed bug GH-8778 (Integer arithmethic with large number variants fails).
|
||||||
(cmb)
|
(cmb)
|
||||||
|
|
|
@ -42,7 +42,6 @@ ZEND_BEGIN_MODULE_GLOBALS(zend_test)
|
||||||
int observer_show_opcode;
|
int observer_show_opcode;
|
||||||
int observer_nesting_depth;
|
int observer_nesting_depth;
|
||||||
int replace_zend_execute_ex;
|
int replace_zend_execute_ex;
|
||||||
zend_bool print_stderr_mshutdown;
|
|
||||||
HashTable global_weakmap;
|
HashTable global_weakmap;
|
||||||
ZEND_END_MODULE_GLOBALS(zend_test)
|
ZEND_END_MODULE_GLOBALS(zend_test)
|
||||||
|
|
||||||
|
@ -408,7 +407,6 @@ PHP_INI_BEGIN()
|
||||||
STD_PHP_INI_BOOLEAN("zend_test.observer.show_init_backtrace", "0", PHP_INI_SYSTEM, OnUpdateBool, observer_show_init_backtrace, zend_zend_test_globals, zend_test_globals)
|
STD_PHP_INI_BOOLEAN("zend_test.observer.show_init_backtrace", "0", PHP_INI_SYSTEM, OnUpdateBool, observer_show_init_backtrace, zend_zend_test_globals, zend_test_globals)
|
||||||
STD_PHP_INI_BOOLEAN("zend_test.observer.show_opcode", "0", PHP_INI_SYSTEM, OnUpdateBool, observer_show_opcode, zend_zend_test_globals, zend_test_globals)
|
STD_PHP_INI_BOOLEAN("zend_test.observer.show_opcode", "0", PHP_INI_SYSTEM, OnUpdateBool, observer_show_opcode, zend_zend_test_globals, zend_test_globals)
|
||||||
STD_PHP_INI_BOOLEAN("zend_test.replace_zend_execute_ex", "0", PHP_INI_SYSTEM, OnUpdateBool, replace_zend_execute_ex, zend_zend_test_globals, zend_test_globals)
|
STD_PHP_INI_BOOLEAN("zend_test.replace_zend_execute_ex", "0", PHP_INI_SYSTEM, OnUpdateBool, replace_zend_execute_ex, zend_zend_test_globals, zend_test_globals)
|
||||||
STD_PHP_INI_BOOLEAN("zend_test.print_stderr_mshutdown", "0", PHP_INI_SYSTEM, OnUpdateBool, print_stderr_mshutdown, zend_zend_test_globals, zend_test_globals)
|
|
||||||
PHP_INI_END()
|
PHP_INI_END()
|
||||||
|
|
||||||
static zend_observer_fcall_handlers observer_fcall_init(zend_execute_data *execute_data);
|
static zend_observer_fcall_handlers observer_fcall_init(zend_execute_data *execute_data);
|
||||||
|
@ -528,10 +526,6 @@ PHP_MSHUTDOWN_FUNCTION(zend_test)
|
||||||
UNREGISTER_INI_ENTRIES();
|
UNREGISTER_INI_ENTRIES();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ZT_G(print_stderr_mshutdown)) {
|
|
||||||
fprintf(stderr, "[zend-test] MSHUTDOWN\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
--TEST--
|
|
||||||
CLI: stderr is available in mshutdown
|
|
||||||
--SKIPIF--
|
|
||||||
<?php
|
|
||||||
if (!extension_loaded('zend-test')) die('skip zend-test extension required');
|
|
||||||
if (php_sapi_name() != "cli") die('skip cli test only');
|
|
||||||
?>
|
|
||||||
--INI--
|
|
||||||
zend_test.print_stderr_mshutdown=1
|
|
||||||
--FILE--
|
|
||||||
==DONE==
|
|
||||||
--EXPECTF--
|
|
||||||
==DONE==
|
|
||||||
[zend-test] MSHUTDOWN
|
|
|
@ -539,14 +539,6 @@ static void cli_register_file_handles(void) /* {{{ */
|
||||||
s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out);
|
s_out = php_stream_open_wrapper_ex("php://stdout", "wb", 0, NULL, sc_out);
|
||||||
s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err);
|
s_err = php_stream_open_wrapper_ex("php://stderr", "wb", 0, NULL, sc_err);
|
||||||
|
|
||||||
/* Release stream resources, but don't free the underlying handles. Othewrise,
|
|
||||||
* extensions which write to stderr or company during mshutdown/gshutdown
|
|
||||||
* won't have the expected functionality.
|
|
||||||
*/
|
|
||||||
if (s_in) s_in->flags |= PHP_STREAM_FLAG_NO_CLOSE;
|
|
||||||
if (s_out) s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;
|
|
||||||
if (s_err) s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
|
|
||||||
|
|
||||||
if (s_in==NULL || s_out==NULL || s_err==NULL) {
|
if (s_in==NULL || s_out==NULL || s_err==NULL) {
|
||||||
if (s_in) php_stream_close(s_in);
|
if (s_in) php_stream_close(s_in);
|
||||||
if (s_out) php_stream_close(s_out);
|
if (s_out) php_stream_close(s_out);
|
||||||
|
@ -554,6 +546,12 @@ static void cli_register_file_handles(void) /* {{{ */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PHP_DEBUG
|
||||||
|
/* do not close stdout and stderr */
|
||||||
|
s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;
|
||||||
|
s_err->flags |= PHP_STREAM_FLAG_NO_CLOSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
s_in_process = s_in;
|
s_in_process = s_in;
|
||||||
|
|
||||||
php_stream_to_zval(s_in, &ic.value);
|
php_stream_to_zval(s_in, &ic.value);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue