-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Fix GH-22849: error_include_args=1 mishandled for include() #22851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NattyNarwhal
wants to merge
1
commit into
php:master
Choose a base branch
from
NattyNarwhal:gh22849
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+50
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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");'); | ||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| } | ||||||||
|
|
||||||||
| /* get a backtrace to snarf function args */ | ||||||||
| zval backtrace; | ||||||||
| zend_fetch_debug_backtrace(&backtrace, /* skip_last */ 0, /* options */ 0, /* limit */ 1); | ||||||||
|
|
||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.