Skip to content

simple ignore arguments in exceptions implementation #4282

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

Closed
Closed
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
18 changes: 18 additions & 0 deletions Zend/tests/exception_ignore_args.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Exceptions ignoring arguments
--FILE--
<?php
$function = function(string $user, string $pass) {
throw new Exception();
};

ini_set("zend.exception_ignore_args", 1);

$function("secrets", "arewrong");
?>
--EXPECTF--
Fatal error: Uncaught Exception in %sexception_ignore_args.php:3
Stack trace:
#0 %sexception_ignore_args.php(8): {closure}()
#1 {main}
thrown in %sexception_ignore_args.php on line 3
1 change: 1 addition & 0 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ ZEND_INI_BEGIN()
#ifdef ZEND_SIGNALS
STD_ZEND_INI_BOOLEAN("zend.signal_check", "0", ZEND_INI_SYSTEM, OnUpdateBool, check, zend_signal_globals_t, zend_signal_globals)
#endif
STD_ZEND_INI_BOOLEAN("zend.exception_ignore_args", "0", ZEND_INI_ALL, OnUpdateBool, exception_ignore_args, zend_executor_globals, executor_globals)
ZEND_INI_END()

ZEND_API size_t zend_vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */
Expand Down
4 changes: 3 additions & 1 deletion Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ static zend_object *zend_default_exception_new_ex(zend_class_entry *class_type,
object_properties_init(object, class_type);

if (EG(current_execute_data)) {
zend_fetch_debug_backtrace(&trace, skip_top_traces, 0, 0);
zend_fetch_debug_backtrace(&trace,
skip_top_traces,
EG(exception_ignore_args) ? DEBUG_BACKTRACE_IGNORE_ARGS : 0, 0);
} else {
array_init(&trace);
}
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ struct _zend_executor_globals {

HashTable weakrefs;

zend_bool exception_ignore_args;

void *reserved[ZEND_MAX_RESERVED_RESOURCES];
};

Expand Down
6 changes: 6 additions & 0 deletions php.ini-development
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,10 @@ zend.enable_gc = On
; Default: ""
;zend.script_encoding =

; Allows to include or exclude arguments from stack traces generated for exceptions
; Default: Off
zend.exception_ignore_args = Off

;;;;;;;;;;;;;;;;;
; Miscellaneous ;
;;;;;;;;;;;;;;;;;
Expand Down Expand Up @@ -1579,6 +1583,8 @@ zend.assertions = 1
; http://php.net/assert.quiet-eval
;assert.quiet_eval = 0



[COM]
; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs
; http://php.net/com.typelib-file
Expand Down
6 changes: 6 additions & 0 deletions php.ini-production
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ zend.enable_gc = On
; Default: ""
;zend.script_encoding =

; Allows to include or exclude arguments from stack traces generated for exceptions
; Default: Off
; In production, it is recommended to turn this setting on to prohibit the output
; of sensitive information in stack traces
zend.exception_ignore_args = On

;;;;;;;;;;;;;;;;;
; Miscellaneous ;
;;;;;;;;;;;;;;;;;
Expand Down