dmitry Wed Apr 27 11:44:07 2005 EDT
Added files: (Branch: PHP_5_0)
/ZendEngine2/tests bug29210.phpt
Modified files:
/php-src NEWS
/ZendEngine2 zend_API.c zend_API.h zend_object_handlers.c
zend_object_handlers.h
/php-src/ext/standard basic_functions.c
Log:
Fixed bug #29210 (Function: is_callable - no support for private and
protected classes).
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.353&r2=1.1760.2.354&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1760.2.353 php-src/NEWS:1.1760.2.354
--- php-src/NEWS:1.1760.2.353 Wed Apr 27 10:30:31 2005
+++ php-src/NEWS Wed Apr 27 11:44:05 2005
@@ -60,6 +60,8 @@
(Dmitry)
- Fixed bug #29944 (Function defined in switch, crashes). (Dmitry)
- Fixed bug #29583 (crash when echoing a COM object). (M.Sisolak, Wez)
+- Fixed bug #29210 (Function: is_callable - no support for private and
+ protected classes). (Dmitry)
- Fixed bug #29104 (Function declaration in method doesn't work). (Dmitry)
- Fixed bug #28839 (SIGSEGV in interactive mode (php -a)).
(kameshj at fastmail dot fm)
http://cvs.php.net/diff.php/ZendEngine2/zend_API.c?r1=1.256.2.12&r2=1.256.2.13&ty=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.256.2.12 ZendEngine2/zend_API.c:1.256.2.13
--- ZendEngine2/zend_API.c:1.256.2.12 Tue Apr 26 05:27:07 2005
+++ ZendEngine2/zend_API.c Wed Apr 27 11:44:06 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.256.2.12 2005/04/26 09:27:07 dmitry Exp $ */
+/* $Id: zend_API.c,v 1.256.2.13 2005/04/27 15:44:06 dmitry Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -1717,7 +1717,7 @@
return 1;
}
-ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only,
char **callable_name)
+ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, char
**callable_name)
{
char *lcname;
zend_bool retval = 0;
@@ -1728,7 +1728,7 @@
if (callable_name) {
*callable_name = estrndup(Z_STRVAL_P(callable),
Z_STRLEN_P(callable));
}
- if (syntax_only) {
+ if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) {
return 1;
}
@@ -1765,7 +1765,7 @@
memcpy(ptr,
Z_STRVAL_PP(method), Z_STRLEN_PP(method) + 1);
}
- if (syntax_only)
+ if (check_flags &
IS_CALLABLE_CHECK_SYNTAX_ONLY)
return 1;
lcname =
zend_str_tolower_dup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj));
@@ -1794,14 +1794,28 @@
memcpy(ptr,
Z_STRVAL_PP(method), Z_STRLEN_PP(method) + 1);
}
- if (syntax_only)
+ if (check_flags &
IS_CALLABLE_CHECK_SYNTAX_ONLY)
return 1;
}
if (ce) {
+ zend_function *fbc;
+
lcname =
zend_str_tolower_dup(Z_STRVAL_PP(method), Z_STRLEN_PP(method));
- if
(zend_hash_exists(&ce->function_table, lcname, Z_STRLEN_PP(method)+1)) {
+ if
(zend_hash_find(&ce->function_table, lcname, Z_STRLEN_PP(method)+1, (void
**)&fbc) == SUCCESS) {
retval = 1;
+ if ((check_flags &
IS_CALLABLE_CHECK_NO_ACCESS) == 0) {
+ if
(fbc->op_array.fn_flags & ZEND_ACC_PRIVATE) {
+ if
(!zend_check_private(fbc, (Z_TYPE_PP(obj) ==
IS_STRING)?EG(scope):(*obj)->value.obj.handlers->get_class_entry(*obj
TSRMLS_CC), lcname, Z_STRLEN_PP(method) TSRMLS_CC)) {
+
retval = 0;
+ }
+ } else if
((fbc->common.fn_flags & ZEND_ACC_PROTECTED)) {
+ if
(!zend_check_protected(fbc->common.scope, EG(scope))) {
+
retval = 0;
+ }
+ }
+ }
+
}
/* check for __call too */
if (retval == 0 && ce->__call
!= 0) {
http://cvs.php.net/diff.php/ZendEngine2/zend_API.h?r1=1.185.2.2&r2=1.185.2.3&ty=u
Index: ZendEngine2/zend_API.h
diff -u ZendEngine2/zend_API.h:1.185.2.2 ZendEngine2/zend_API.h:1.185.2.3
--- ZendEngine2/zend_API.h:1.185.2.2 Sat Jan 22 07:29:13 2005
+++ ZendEngine2/zend_API.h Wed Apr 27 11:44:06 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.h,v 1.185.2.2 2005/01/22 12:29:13 helly Exp $ */
+/* $Id: zend_API.h,v 1.185.2.3 2005/04/27 15:44:06 dmitry Exp $ */
#ifndef ZEND_API_H
#define ZEND_API_H
@@ -179,7 +179,11 @@
ZEND_API int zend_disable_class(char *class_name, uint class_name_length
TSRMLS_DC);
ZEND_API void zend_wrong_param_count(TSRMLS_D);
-ZEND_API zend_bool zend_is_callable(zval *callable, zend_bool syntax_only,
char **callable_name);
+
+#define IS_CALLABLE_CHECK_SYNTAX_ONLY (1<<0)
+#define IS_CALLABLE_CHECK_NO_ACCESS (1<<1)
+
+ZEND_API zend_bool zend_is_callable(zval *callable, uint check_flags, char
**callable_name);
ZEND_API zend_bool zend_make_callable(zval *callable, char **callable_name
TSRMLS_DC);
ZEND_API char *zend_get_module_version(char *module_name);
ZEND_API int zend_get_module_started(char *module_name);
http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.c?r1=1.101.2.7&r2=1.101.2.8&ty=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.101.2.7
ZendEngine2/zend_object_handlers.c:1.101.2.8
--- ZendEngine2/zend_object_handlers.c:1.101.2.7 Sat Mar 19 10:38:19 2005
+++ ZendEngine2/zend_object_handlers.c Wed Apr 27 11:44:06 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.c,v 1.101.2.7 2005/03/19 15:38:19 helly Exp $ */
+/* $Id: zend_object_handlers.c,v 1.101.2.8 2005/04/27 15:44:06 dmitry Exp $ */
#include "zend.h"
#include "zend_globals.h"
@@ -612,7 +612,7 @@
* Returns the function address that should be called, or NULL
* if no such function exists.
*/
-static inline zend_function *zend_check_private(zend_function *fbc,
zend_class_entry *ce, int fn_flags, char *function_name_strval, int
function_name_strlen TSRMLS_DC)
+static inline zend_function *zend_check_private_int(zend_function *fbc,
zend_class_entry *ce, char *function_name_strval, int function_name_strlen
TSRMLS_DC)
{
if (!ce) {
return 0;
@@ -647,6 +647,11 @@
}
+ZEND_API int zend_check_private(zend_function *fbc, zend_class_entry *ce, char
*function_name_strval, int function_name_strlen TSRMLS_DC)
+{
+ return zend_check_private_int(fbc, ce, function_name_strval,
function_name_strlen TSRMLS_CC) != NULL;
+}
+
/* Ensures that we're allowed to call a protected method.
*/
ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry
*scope)
@@ -723,7 +728,7 @@
/* Ensure that if we're calling a private function, we're
allowed to do so.
*/
- updated_fbc = zend_check_private(fbc,
object->value.obj.handlers->get_class_entry(object TSRMLS_CC),
fbc->common.fn_flags, lc_method_name, method_len TSRMLS_CC);
+ updated_fbc = zend_check_private_int(fbc,
object->value.obj.handlers->get_class_entry(object TSRMLS_CC), lc_method_name,
method_len TSRMLS_CC);
if (!updated_fbc) {
zend_error(E_ERROR, "Call to %s method %s::%s() from
context '%s'", zend_visibility_string(fbc->common.fn_flags),
ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : "");
}
@@ -761,7 +766,7 @@
/* Ensure that if we're calling a private function, we're
allowed to do so.
*/
- updated_fbc = zend_check_private(fbc, EG(scope),
fbc->common.fn_flags, function_name_strval, function_name_strlen TSRMLS_CC);
+ updated_fbc = zend_check_private_int(fbc, EG(scope),
function_name_strval, function_name_strlen TSRMLS_CC);
if (!updated_fbc) {
zend_error(E_ERROR, "Call to %s method %s::%s() from
context '%s'", zend_visibility_string(fbc->common.fn_flags),
ZEND_FN_SCOPE_NAME(fbc), function_name_strval, EG(scope) ? EG(scope)->name :
"");
}
http://cvs.php.net/diff.php/ZendEngine2/zend_object_handlers.h?r1=1.41.2.2&r2=1.41.2.3&ty=u
Index: ZendEngine2/zend_object_handlers.h
diff -u ZendEngine2/zend_object_handlers.h:1.41.2.2
ZendEngine2/zend_object_handlers.h:1.41.2.3
--- ZendEngine2/zend_object_handlers.h:1.41.2.2 Thu Nov 25 15:26:48 2004
+++ ZendEngine2/zend_object_handlers.h Wed Apr 27 11:44:06 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_object_handlers.h,v 1.41.2.2 2004/11/25 20:26:48 zeev Exp $ */
+/* $Id: zend_object_handlers.h,v 1.41.2.3 2005/04/27 15:44:06 dmitry Exp $ */
#ifndef ZEND_OBJECT_HANDLERS_H
#define ZEND_OBJECT_HANDLERS_H
@@ -137,6 +137,8 @@
#define IS_ZEND_STD_OBJECT(z) ((z).type == IS_OBJECT &&
(Z_OBJ_HT((z))->get_class_entry != NULL))
#define HAS_CLASS_ENTRY(z) (Z_OBJ_HT(z)->get_class_entry != NULL)
+ZEND_API int zend_check_private(union _zend_function *fbc, zend_class_entry
*ce, char *function_name_strval, int function_name_strlen TSRMLS_DC);
+
ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry
*scope);
ZEND_API int zend_check_property_access(zend_object *zobj, char
*prop_info_name TSRMLS_DC);
http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.673.2.15&r2=1.673.2.16&ty=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.673.2.15
php-src/ext/standard/basic_functions.c:1.673.2.16
--- php-src/ext/standard/basic_functions.c:1.673.2.15 Thu Apr 21 10:45:55 2005
+++ php-src/ext/standard/basic_functions.c Wed Apr 27 11:44:06 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.673.2.15 2005/04/21 14:45:55 sniper Exp $ */
+/* $Id: basic_functions.c,v 1.673.2.16 2005/04/27 15:44:06 dmitry Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -1908,7 +1908,7 @@
convert_to_string_ex(params[0]);
}
- if (!zend_is_callable(*params[0], 0, &name)) {
+ if (!zend_is_callable(*params[0], IS_CALLABLE_CHECK_NO_ACCESS, &name)) {
php_error_docref1(NULL TSRMLS_CC, name, E_WARNING, "First
argument is expected to be a valid callback");
efree(name);
efree(params);
@@ -1963,7 +1963,7 @@
convert_to_string_ex(func);
}
- if (!zend_is_callable(*func, 0, &name)) {
+ if (!zend_is_callable(*func, IS_CALLABLE_CHECK_NO_ACCESS, &name)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "First argument is
expected to be a valid callback, '%s' was given", name);
efree(name);
RETURN_NULL();
http://cvs.php.net/co.php/ZendEngine2/tests/bug29210.phpt?r=1.1&p=1
Index: ZendEngine2/tests/bug29210.phpt
+++ ZendEngine2/tests/bug29210.phpt
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php