com php-src: Make visibilty check in is_callable() to be consistent with zend_std_get_method(): Zend/zend_API.c

From: Date: Thu, 13 Sep 2018 09:24:59 +0000
Subject: com php-src: Make visibilty check in is_callable() to be consistent with zend_std_get_method(): Zend/zend_API.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-103097@lists.php.net to get a copy of this message
Commit: 72bf2def6b718ae9ca243b6a9ab9a3a85d255f96 Author: Dmitry Stogov <dmitry@zend.com> Thu, 13 Sep 2018 12:24:59 +0300 Parents: 67a75a79ae0c4b321ed0a6ed53326214a9a6b325 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=72bf2def6b718ae9ca243b6a9ab9a3a85d255f96 Log: Make visibilty check in is_callable() to be consistent with zend_std_get_method() Changed paths: M Zend/zend_API.c Diff: diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 0cf6ef0..7f7a9d7 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -3097,24 +3097,17 @@ static zend_always_inline int zend_is_callable_check_func(int check_flags, zval } } } - if ((check_flags & IS_CALLABLE_CHECK_NO_ACCESS) == 0 && + if (!(fcc->function_handler->common.fn_flags & ZEND_ACC_PUBLIC) && + !(check_flags & IS_CALLABLE_CHECK_NO_ACCESS) && (fcc->calling_scope && ((fcc->object && fcc->calling_scope->__call) || (!fcc->object && fcc->calling_scope->__callstatic)))) { - if (fcc->function_handler->op_array.fn_flags & ZEND_ACC_PRIVATE) { - scope = zend_get_executed_scope(); - if (!zend_check_private(fcc->function_handler, fcc->object ? fcc->object->ce : scope, lmname)) { - retval = 0; - fcc->function_handler = NULL; - goto get_function_via_handler; - } - } else if (fcc->function_handler->common..fn_flags & ZEND_ACC_PROTECTED) { - scope = zend_get_executed_scope(); - if (!zend_check_protected(fcc->function_handler->common.scope, scope)) { - retval = 0; - fcc->function_handler = NULL; - goto get_function_via_handler; - } + scope = zend_get_executed_scope(); + if (fcc->function_handler->common.scope != scope + || !zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope)) { + retval = 0; + fcc->function_handler = NULL; + goto get_function_via_handler; } } } else { @@ -3200,26 +3193,18 @@ get_function_via_handler: } } } - if (retval && (check_flags & IS_CALLABLE_CHECK_NO_ACCESS) == 0) { - if (fcc->function_handler->op_array.fn_flags & ZEND_ACC_PRIVATE) { - scope = zend_get_executed_scope(); - if (!zend_check_private(fcc->function_handler, fcc->object ? fcc->object->ce : scope, lmname)) { - if (error) { - if (*error) { - efree(*error); - } - zend_spprintf(error, 0, "cannot access private method %s::%s()", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name)); - } - retval = 0; - } - } else if ((fcc->function_handler->common.fn_flags & ZEND_ACC_PROTECTED)) { - scope = zend_get_executed_scope(); - if (!zend_check_protected(fcc->function_handler->common.scope, scope)) { + if (retval + && !(fcc->function_handler->common.fn_flags & ZEND_ACC_PUBLIC) + && !(check_flags & IS_CALLABLE_CHECK_NO_ACCESS)) { + scope = zend_get_executed_scope(); + if (fcc->function_handler->common.scope != scope) { + if ((fcc->function_handler->common.fn_flags & ZEND_ACC_PRIVATE) + || (!zend_check_protected(zend_get_function_root_class(fcc->function_handler), scope))) { if (error) { if (*error) { efree(*error); } - zend_spprintf(error, 0, "cannot access protected method %s::%s()", ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name)); + zend_spprintf(error, 0, "cannot access %s method %s::%s()", zend_visibility_string(fcc->function_handler->common.fn_flags), ZSTR_VAL(fcc->calling_scope->name), ZSTR_VAL(fcc->function_handler->common.function_name)); } retval = 0; }

« previous php.cvs (#103097) next »