Skip to content

Commit e775c27

Browse files
committed
Use ZEND_ACC2_FORBID_DYN_CALLS
1 parent 94a88c6 commit e775c27

2 files changed

Lines changed: 1 addition & 26 deletions

File tree

Zend/zend_partial.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -686,27 +686,6 @@ static uint32_t zp_compute_num_required(zend_function *function,
686686
return num_required;
687687
}
688688

689-
/* Functions that do not allow to be called dynamically */
690-
static const zend_known_string_id zp_non_dynamic_call_funcs[] = {
691-
ZEND_STR_COMPACT,
692-
ZEND_STR_EXTRACT,
693-
ZEND_STR_FUNC_GET_ARG,
694-
ZEND_STR_FUNC_GET_ARGS,
695-
ZEND_STR_FUNC_NUM_ARGS,
696-
ZEND_STR_GET_DEFINED_VARS,
697-
};
698-
699-
static bool zp_is_non_dynamic_call_func(zend_function *function)
700-
{
701-
for (size_t i = 0; i < sizeof(zp_non_dynamic_call_funcs) / sizeof(zp_non_dynamic_call_funcs[0]); i++) {
702-
if (zend_string_equals(function->common.function_name, ZSTR_KNOWN(zp_non_dynamic_call_funcs[i]))) {
703-
return true;
704-
}
705-
}
706-
707-
return false;
708-
}
709-
710689
/* Compile PFA to an op_array */
711690
static zend_op_array *zp_compile(zval *this_ptr, zend_function *function,
712691
uint32_t argc, zval *argv, zend_array *extra_named_params,
@@ -717,7 +696,7 @@ static zend_op_array *zp_compile(zval *this_ptr, zend_function *function,
717696

718697
zend_op_array *op_array = NULL;
719698

720-
if (UNEXPECTED(zp_is_non_dynamic_call_func(function))) {
699+
if (UNEXPECTED(function->common.fn_flags2 & ZEND_ACC2_FORBID_DYN_CALLS)) {
721700
zend_throw_error(NULL, "Cannot call %.*s() dynamically",
722701
(int) ZSTR_LEN(function->common.function_name), ZSTR_VAL(function->common.function_name));
723702
return NULL;

Zend/zend_string.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -632,13 +632,9 @@ default: ZEND_UNREACHABLE();
632632
_(ZEND_STR_COUNT, "count") \
633633
_(ZEND_STR_FUNC_NUM_ARGS, "func_num_args") \
634634
_(ZEND_STR_FUNC_GET_ARGS, "func_get_args") \
635-
_(ZEND_STR_FUNC_GET_ARG, "func_get_arg") \
636-
_(ZEND_STR_COMPACT, "compact") \
637-
_(ZEND_STR_EXTRACT, "extract") \
638635
_(ZEND_STR_ASSERT, "assert") \
639636
_(ZEND_STR_CALL_USER_FUNC, "call_user_func") \
640637
_(ZEND_STR_ARRAY_SLICE, "array_slice") \
641-
_(ZEND_STR_GET_DEFINED_VARS, "get_defined_vars") \
642638
_(ZEND_STR_SENSITIVEPARAMETER, "SensitiveParameter") \
643639
_(ZEND_STR_CONST_EXPR_PLACEHOLDER, "[constant expression]") \
644640
_(ZEND_STR_DEPRECATED_CAPITALIZED, "Deprecated") \

0 commit comments

Comments
 (0)