Skip to content
Open
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
36 changes: 36 additions & 0 deletions Zend/tests/gh22849.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
PHP 8.6 error_include_args=1 mishandled for include()
--INI--
error_include_args=On
--FILE--
<?php

function foo() {
eval('include("does not exist");');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how much value this line provides, since it's not eval() itself that emits the warning.

include("does not exist");
include_once("does not exist");
require("does not exist");
}

foo(1, 2);
?>
--EXPECTF--
Warning: include('does not exist'): Failed to open stream: No such file or directory in %s on line %d

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

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

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

Warning: include_once('does not exist'): Failed to open stream: No such file or directory in %s on line %d

Warning: include_once('does not exist'): Failed opening 'does not exist' for inclusion (include_path='%s') in %s on line %d

Warning: require('does not exist'): Failed to open stream: No such file or directory in %s on line %d

Fatal error: Uncaught Error: Failed opening required 'does not exist' (include_path='%s') in %s:%d
Stack trace:
#0 %s(%d): foo(1, 2)
#1 {main}
thrown in %s on line %d
14 changes: 14 additions & 0 deletions Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,20 @@ ZEND_API zend_string *zend_trace_function_args_to_string(const HashTable *frame)
/* {{{ Gets the currently executing function's arguments as a string. Used by php_verror. */
ZEND_API zend_string *zend_trace_current_function_args_string(void) {
zend_string *dynamic_params = NULL;
/* Special case: require_once/include_once aren't functions, but we
* want to capture their arguments anyways.
*/
zend_execute_data *execute_data = EG(current_execute_data);
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);
smart_str str = {0};
build_trace_args(inc_filename, &str);
dynamic_params = smart_str_extract(&str);
return dynamic_params;
Comment on lines +643 to +644

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dynamic_params = smart_str_extract(&str);
return dynamic_params;
return smart_str_extract(&str);

}

/* get a backtrace to snarf function args */
zval backtrace;
zend_fetch_debug_backtrace(&backtrace, /* skip_last */ 0, /* options */ 0, /* limit */ 1);
Expand Down
Loading