summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-06-03 12:05:00 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-06-04 08:45:27 +0200
commitb8e7b30b4715ae5f052dec428d82b705e29220b7 (patch)
treed1931f23c519db5988417593e06e5d12ea80f36c
parent63bd8f38f4b7e8ffbcbd0ea607e21041ebba2455 (diff)
downloadphp-git-b8e7b30b4715ae5f052dec428d82b705e29220b7.tar.gz
Fix #79668: get_defined_functions(true) may miss functions
Instead of some brittle and unefficient string matching, we can just check for the function handler.
-rw-r--r--NEWS2
-rw-r--r--Zend/tests/bug79668.phpt16
-rw-r--r--Zend/zend_builtin_functions.c13
3 files changed, 21 insertions, 10 deletions
diff --git a/NEWS b/NEWS
index e8bab176df..1b8ff49509 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP NEWS
- Core:
. Fixed bug #79650 (php-win.exe 100% cpu lockup). (cmb)
+ . Fixed bug #79668 (get_defined_functions(true) may miss functions). (cmb,
+ Nikita)
- PDO SQLite:
. Fixed bug #79664 (PDOStatement::getColumnMeta fails on empty result set).
diff --git a/Zend/tests/bug79668.phpt b/Zend/tests/bug79668.phpt
new file mode 100644
index 0000000000..5e73a7469b
--- /dev/null
+++ b/Zend/tests/bug79668.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #79668 (get_defined_functions(true) may miss functions)
+--INI--
+disable_functions=sha1_file,password_hash
+--FILE--
+<?php
+$df = get_defined_functions(true);
+foreach (['sha1', 'sha1_file', 'hash', 'password_hash'] as $funcname) {
+ var_dump(in_array($funcname, $df['internal'], true));
+}
+?>
+--EXPECT--
+bool(true)
+bool(false)
+bool(true)
+bool(false)
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 69fbeec1e1..bc3649a622 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1847,16 +1847,9 @@ static int copy_function_name(zval *zv, int num_args, va_list args, zend_hash_ke
return 0;
}
- if (func->type == ZEND_INTERNAL_FUNCTION) {
- char *disable_functions = INI_STR("disable_functions");
-
- if ((*exclude_disabled == 1) && (disable_functions != NULL)) {
- if (strstr(disable_functions, func->common.function_name->val) == NULL) {
- add_next_index_str(internal_ar, zend_string_copy(hash_key->key));
- }
- } else {
- add_next_index_str(internal_ar, zend_string_copy(hash_key->key));
- }
+ if (func->type == ZEND_INTERNAL_FUNCTION
+ && (!*exclude_disabled || func->internal_function.handler != ZEND_FN(display_disabled_function))) {
+ add_next_index_str(internal_ar, zend_string_copy(hash_key->key));
} else if (func->type == ZEND_USER_FUNCTION) {
add_next_index_str(user_ar, zend_string_copy(hash_key->key));
}