Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PHP NEWS
- Core:
. Changed run-tests.php to run test subprocesses without a shell where
possible. (NickSdot)
. Fixed GH-23083 (SEGV build_trace_args in zend_exceptions.c with
-d error_include_args=On). (David Carlier)

- Curl:
. Improved cURL option validation errors to include the option name.
Expand Down
32 changes: 32 additions & 0 deletions Zend/tests/gh23083.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--TEST--
GH-23083 (SEGV in build_trace_args() with error_include_args=On and a non-literal include argument)
--INI--
error_include_args=On
--FILE--
<?php

$file = 'no_such_file';

/* CV operand */
include $file;

/* TMP operand */
include $file . '_2';

/* CV operand holding a reference */
$ref = &$file;
include $ref;

?>
--EXPECTF--
Warning: include('no_such_file'): Failed to open stream: No such file or directory in %s on line %d

Warning: include('no_such_file'): Failed opening 'no_such_file' for inclusion (include_path='%s') in %s on line %d

Warning: include('no_such_file_2'): Failed to open stream: No such file or directory in %s on line %d

Warning: include('no_such_file_2'): Failed opening 'no_such_file_2' for inclusion (include_path='%s') in %s on line %d

Warning: include('no_such_file'): Failed to open stream: No such file or directory in %s on line %d

Warning: include('no_such_file'): Failed opening 'no_such_file' for inclusion (include_path='%s') in %s on line %d
12 changes: 11 additions & 1 deletion Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,17 @@ ZEND_API zend_string *zend_trace_current_function_args_string(void) {
if (execute_data && execute_data->func
&& ZEND_USER_CODE(execute_data->func->common.type)
&& (execute_data->opline->opcode == ZEND_INCLUDE_OR_EVAL)) {
zval *inc_filename = RT_CONSTANT(execute_data->opline, execute_data->opline->op1);
zval *inc_filename;

switch (execute_data->opline->op1_type) {
/* op1 may be CONST, TMP or CV; RT_CONSTANT() is only valid for the former. */
case IS_CONST:
inc_filename = RT_CONSTANT(execute_data->opline, execute_data->opline->op1);
break;
default:
inc_filename = EX_VAR(execute_data->opline->op1.var);
}

smart_str str = {0};
build_trace_args(inc_filename, &str);
return smart_str_extract(&str);
Expand Down