-
Notifications
You must be signed in to change notification settings - Fork 8k
Aggressively use actual function parameters in php_verror
#12276
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
base: master
Are you sure you want to change the base?
Changes from 14 commits
967fa4e
502acc3
63b7a4f
b83d4d9
db2184a
f4a43ea
a6f5a3b
b4a67d6
e788673
1e981ce
fdb57ae
7a81b0e
7840f27
11ddadf
5e43726
b289770
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| --TEST-- | ||
| Displaying function arguments in errors | ||
| --INI-- | ||
| error_ignore_args=Off | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| // A function that sets its own parameters in docref call, to compare | ||
| unlink('/'); | ||
| // Something with sensitive parameters that exists in a minimal build, | ||
| // and also doesn't set anything in the docref call | ||
| // XXX: May be better to provide a new zend_test func? | ||
| password_hash("test", PASSWORD_BCRYPT, array("salt" => "123456789012345678901" . chr(0))); | ||
|
|
||
| ini_set("error_ignore_args", "On"); | ||
|
|
||
| unlink('/'); | ||
| password_hash("test", PASSWORD_BCRYPT, array("salt" => "123456789012345678901" . chr(0))); | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Warning: unlink('/'): %s in %s on line %d | ||
|
|
||
| Warning: password_hash(Object(SensitiveParameterValue), '2y', Array): The "salt" option has been ignored, since providing a custom salt is no longer supported in %s on line %d | ||
|
|
||
| Warning: unlink(/): %s in %s on line %d | ||
|
|
||
| Warning: password_hash(): The "salt" option has been ignored, since providing a custom salt is no longer supported in %s on line %d |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -64,6 +64,7 @@ | |||||
| #include "win32/php_registry.h" | ||||||
| #include "ext/standard/flock_compat.h" | ||||||
| #endif | ||||||
| #include "Zend/zend_builtin_functions.h" | ||||||
| #include "Zend/zend_exceptions.h" | ||||||
|
|
||||||
| #if PHP_SIGCHILD | ||||||
|
|
@@ -803,6 +804,7 @@ PHP_INI_BEGIN() | |||||
| STD_PHP_INI_ENTRY_EX("display_errors", "1", PHP_INI_ALL, OnUpdateDisplayErrors, display_errors, php_core_globals, core_globals, display_errors_mode) | ||||||
| STD_PHP_INI_BOOLEAN("display_startup_errors", "1", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals) | ||||||
| STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals) | ||||||
| STD_PHP_INI_BOOLEAN("error_ignore_args", "0", PHP_INI_ALL, OnUpdateBool, error_ignore_args, php_core_globals, core_globals) | ||||||
| STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals) | ||||||
| STD_PHP_INI_ENTRY("docref_root", "", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals) | ||||||
| STD_PHP_INI_ENTRY("docref_ext", "", PHP_INI_ALL, OnUpdateString, docref_ext, php_core_globals, core_globals) | ||||||
|
|
@@ -1134,7 +1136,18 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ | |||||
|
|
||||||
| /* if we still have memory then format the origin */ | ||||||
| if (is_function) { | ||||||
| origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, params); | ||||||
| zend_string *dynamic_params = NULL; | ||||||
| /* | ||||||
| * By default, this is disabled because it requires rewriting | ||||||
|
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. I suggest taking a look at https://wiki.php.net/rfc/error_backtraces_v2 and its discussion - you can have the default be true generally, and then false for tests |
||||||
| * almost all PHPT files. | ||||||
| */ | ||||||
|
NattyNarwhal marked this conversation as resolved.
Outdated
|
||||||
| if (PG(error_ignore_args) == false) { | ||||||
|
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. Is this condition inverted now?
Suggested change
|
||||||
| dynamic_params = zend_trace_current_function_args_string(); | ||||||
| } | ||||||
| origin_len = spprintf(&origin, 0, "%s%s%s(%s)", class_name, space, function, dynamic_params ? ZSTR_VAL(dynamic_params) : params); | ||||||
| if (dynamic_params) { | ||||||
| zend_string_release(dynamic_params); | ||||||
| } | ||||||
| } else { | ||||||
| origin_len = strlen(function); | ||||||
| origin = estrndup(function, origin_len); | ||||||
|
|
||||||
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.
Is this expected to emit errors during regular operation? Otherwise I would find it okay to leave out that option here and fix a (small) number of tests.
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.
One test (
sapi/cli/tests/gh18582.phpt) does so. I set it here to make them consistent across all tests in case more are added; if not appropriate, it can be moved to that test with thecmd_argsparameter on the server function.