From d976be4bda9c3af7000b1ee7af0e2026bef7a0a4 Mon Sep 17 00:00:00 2001 From: Scott MacVicar Date: Fri, 19 Jun 2009 03:29:47 +0000 Subject: [PATCH] Make the check case sensitive, and since we can only have a constructor that matches the class name or is __construct its probably safe to just check for __. This means we can skip lowering the function_name, which is hard to be binary safe sine we don't store the length. If we just did a zend_hash_exists lookup we'd be fine since its stored lowercased already :) --- Zend/tests/bug48215_2.phpt | 22 ++++++++++++++++++++++ Zend/zend_object_handlers.c | 6 ++++-- 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 Zend/tests/bug48215_2.phpt diff --git a/Zend/tests/bug48215_2.phpt b/Zend/tests/bug48215_2.phpt new file mode 100644 index 0000000000..30f0734ace --- /dev/null +++ b/Zend/tests/bug48215_2.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #48215 - parent::method() calls __construct, case sensitive test +--FILE-- + +===DONE=== +--EXPECTF-- + +Strict Standards: Redefining already defined constructor for class a in %s on line %d + +Fatal error: Call to undefined method b::b() in %s on line %d diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index 6848977ae3..59a4260ff2 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -942,8 +942,10 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, char *f if (function_name_strlen == ce->name_length && ce->constructor) { lc_class_name = zend_str_tolower_dup(ce->name, ce->name_length); - /* Only change the method to the constructor if a __construct() method doesn't exist */ - if (!memcmp(lc_class_name, function_name_strval, function_name_strlen) && memcmp(ce->constructor->common.function_name, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) { + /* Only change the method to the constructor if the constructor isn't called __construct + * we check for __ so we can be binary safe for lowering, we should use ZEND_CONSTRUCTOR_FUNC_NAME + */ + if (!memcmp(lc_class_name, function_name_strval, function_name_strlen) && memcmp(ce->constructor->common.function_name, "__", sizeof("__") - 1)) { fbc = ce->constructor; } efree(lc_class_name); -- 2.40.0