summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-08-10 10:28:13 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-08-10 11:15:16 +0200
commitee163161480f4196d618036728f4765de7139068 (patch)
tree1356ef94a66f74844456ccbd23e823a2b9706cc8 /sapi
parent1974522a2dd571a7ee4dd542e100379c1d450bf6 (diff)
downloadphp-git-ee163161480f4196d618036728f4765de7139068.tar.gz
Fixed bug #79948
Make sure we don't execute further scripts if one of them encountered an exit exception. Also make sure that we free file handles that end up unused due to an early abort in php_execute_scripts(), which turned up as an issue in the added test case. Finally, make use of EG(exit_status) in the places where we zend_eval_string_ex, instead of unconditionally assigning exit code 254. If an error occurs, the error handler will already set exit status 255.
Diffstat (limited to 'sapi')
-rw-r--r--sapi/cli/php_cli.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 4874e0920c..81bad21ae6 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -979,9 +979,8 @@ static int do_cli(int argc, char **argv) /* {{{ */
break;
case PHP_MODE_CLI_DIRECT:
cli_register_file_handles();
- if (zend_eval_string_ex(exec_direct, NULL, "Command line code", 1) == FAILURE) {
- exit_status=254;
- }
+ zend_eval_string_ex(exec_direct, NULL, "Command line code", 1);
+ exit_status = EG(exit_status);
break;
case PHP_MODE_PROCESS_STDIN:
@@ -993,7 +992,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
cli_register_file_handles();
if (exec_begin && zend_eval_string_ex(exec_begin, NULL, "Command line begin code", 1) == FAILURE) {
- exit_status=254;
+ exit_status = EG(exit_status);
}
while (exit_status == SUCCESS && (input=php_stream_gets(s_in_process, NULL, 0)) != NULL) {
len = strlen(input);
@@ -1006,7 +1005,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
zend_hash_str_update(&EG(symbol_table), "argi", sizeof("argi")-1, &argi);
if (exec_run) {
if (zend_eval_string_ex(exec_run, NULL, "Command line run code", 1) == FAILURE) {
- exit_status=254;
+ exit_status = EG(exit_status);
}
} else {
if (script_file) {
@@ -1022,7 +1021,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
efree(input);
}
if (exec_end && zend_eval_string_ex(exec_end, NULL, "Command line end code", 1) == FAILURE) {
- exit_status=254;
+ exit_status = EG(exit_status);
}
break;