cvs: ZendEngine2(PHP_5_0) / zend.c zend_builtin_functions.c zend_compile.c zend_compile.h zend_execute.c zend_reflection_api.c

From: Date: Tue, 20 Sep 2005 11:38:40 +0000
Subject: cvs: ZendEngine2(PHP_5_0) / zend.c zend_builtin_functions.c zend_compile.c zend_compile.h zend_execute.c zend_reflection_api.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-4152@lists.php.net to get a copy of this message
tony2001 Tue Sep 20 07:38:40 2005 EDT Modified files: (Branch: PHP_5_0) /ZendEngine2 zend_reflection_api.c zend_compile.c zend_compile.h zend_builtin_functions.c zend.c zend_execute.c Log: MF5.1: fix #34505 (Possible memory corruption when unmangling properties with empty names)

http://cvs.php.net/diff.php/ZendEngine2/zend_reflection_api.c?r1=1.111.2.27&r2=1.111.2.28&ty=u Index: ZendEngine2/zend_reflection_api.c diff -u ZendEngine2/zend_reflection_api.c:1.111.2.27 ZendEngine2/zend_reflection_api.c:1.111.2.28 --- ZendEngine2/zend_reflection_api.c:1.111.2.27 Sun Sep 18 06:38:25 2005 +++ ZendEngine2/zend_reflection_api.c Tue Sep 20 07:38:36 2005 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_reflection_api.c,v 1.111.2.27 2005/09/18 10:38:25 tony2001 Exp $ */ +/* $Id: zend_reflection_api.c,v 1.111.2.28 2005/09/20 11:38:36 tony2001 Exp $ */ #include "zend.h" #include "zend_API.h" #include "zend_exceptions.h" @@ -683,7 +683,7 @@ string_printf(str, "static "); } - zend_unmangle_property_name(prop->name, &class_name, &prop_name); + zend_unmangle_property_name_ex(prop->name, prop->name_length, &class_name, &prop_name); string_printf(str, "$%s", prop_name); } @@ -941,7 +941,7 @@ property_reference *reference; char *class_name, *prop_name; - zend_unmangle_property_name(prop->name, &class_name, &prop_name); + zend_unmangle_property_name_ex(prop->name, prop->name_length, &class_name, &prop_name); if (!(prop->flags & ZEND_ACC_PRIVATE)) { /* we have to seach the class hierarchy for this (implicit) public or protected property */ @@ -2167,7 +2167,7 @@ zend_hash_get_current_key_ex(&ce->default_properties, &key, &key_len, &num_index, 0, &pos); zend_hash_move_forward_ex(&ce->default_properties, &pos); - zend_unmangle_property_name(key, &class_name, &prop_name); + zend_unmangle_property_name_ex(key, key_len, &class_name, &prop_name); if (class_name && class_name[0] != '*' && strcmp(class_name, ce->name)) { /* filter privates from base classes */ continue; @@ -2938,7 +2938,7 @@ ZVAL_STRINGL(classname, ce->name, ce->name_length, 1); zend_hash_update(Z_OBJPROP_P(object), "class", sizeof("class"), (void **) &classname, sizeof(zval *), NULL); - zend_unmangle_property_name(property_info->name, &class_name, &prop_name); + zend_unmangle_property_name_ex(property_info->name, property_info->name_length, &class_name, &prop_name); MAKE_STD_ZVAL(propname); ZVAL_STRING(propname, prop_name, 1); zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &propname, sizeof(zval *), NULL); http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.567.2.30&r2=1.567.2.31&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.567.2.30 ZendEngine2/zend_compile.c:1.567.2.31 --- ZendEngine2/zend_compile.c:1.567.2.30 Tue Jul 19 03:33:24 2005 +++ ZendEngine2/zend_compile.c Tue Sep 20 07:38:37 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.567.2.30 2005/07/19 07:33:24 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.567.2.31 2005/09/20 11:38:37 tony2001 Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1922,7 +1922,7 @@ if (zend_hash_find(ce->static_members, child_info->name, child_info->name_length+1, (void**)&new_prop) == SUCCESS) { if (Z_TYPE_PP(new_prop) != IS_NULL && Z_TYPE_PP(prop) != IS_NULL) { char *prop_name, *tmp; - zend_unmangle_property_name(child_info->name, &tmp, &prop_name); + zend_unmangle_property_name_ex(child_info->name, child_info->name_length, &tmp, &prop_name); zend_error(E_COMPILE_ERROR, "Cannot change initial value of property static protected %s::$%s in class %s", parent_ce->name, prop_name, ce->name); @@ -2686,6 +2686,18 @@ } +ZEND_API void zend_unmangle_property_name_ex(char *mangled_property, int mangled_property_len, char **class_name, char **prop_name) +{ + *prop_name = *class_name = NULL; + + if (mangled_property_len < 2) { /* do not try to unmangle empty strings */ + *prop_name = mangled_property; + return; + } + + zend_unmangle_property_name(mangled_property, class_name, prop_name); +} + ZEND_API void zend_unmangle_property_name(char *mangled_property, char **class_name, char **prop_name) { *prop_name = *class_name = NULL; http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.284.2.6&r2=1.284.2.7&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.284.2.6 ZendEngine2/zend_compile.h:1.284.2.7 --- ZendEngine2/zend_compile.h:1.284.2.6 Fri Jun 24 04:45:43 2005 +++ ZendEngine2/zend_compile.h Tue Sep 20 07:38:37 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.284.2.6 2005/06/24 08:45:43 dmitry Exp $ */ +/* $Id: zend_compile.h,v 1.284.2.7 2005/09/20 11:38:37 tony2001 Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -506,6 +506,7 @@ ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, char *src1, int src1_length, char *src2, int src2_length, int internal); ZEND_API void zend_unmangle_property_name(char *mangled_property, char **prop_name, char **class_name); +ZEND_API void zend_unmangle_property_name_ex(char *mangled_property, int mangled_property_len, char **prop_name, char **class_name); #define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor #define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.239.2.27&r2=1.239.2.28&ty=u Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.239.2.27 ZendEngine2/zend_builtin_functions.c:1.239.2.28 --- ZendEngine2/zend_builtin_functions.c:1.239.2.27 Mon Jun 27 13:42:06 2005 +++ ZendEngine2/zend_builtin_functions.c Tue Sep 20 07:38:37 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.239.2.27 2005/06/27 17:42:06 stas Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.239.2.28 2005/09/20 11:38:37 tony2001 Exp $ */ #include "zend.h" #include "zend_API.h" @@ -679,7 +679,7 @@ zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos); zend_hash_move_forward_ex(properties, &pos); - zend_unmangle_property_name(key, &class_name, &prop_name); + zend_unmangle_property_name_ex(key, key_len, &class_name, &prop_name); if (class_name) { if (class_name[0] != '*' && strcmp(class_name, ce->name)) { /* filter privates from base classes */ @@ -770,7 +770,7 @@ (*value)->refcount++; add_assoc_zval_ex(return_value, key, key_len, *value); } else if (instanceof) { - zend_unmangle_property_name(key, &class_name, &prop_name); + zend_unmangle_property_name_ex(key, key_len, &class_name, &prop_name); if (!memcmp(class_name, "*", 2) || (Z_OBJCE_P(EG(This)) == Z_OBJCE_PP(obj) && !strcmp(Z_OBJCE_P(EG(This))->name, class_name))) { /* Not separating references */ (*value)->refcount++; http://cvs.php.net/diff.php/ZendEngine2/zend.c?r1=1.287.2.12&r2=1.287.2.13&ty=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.287.2.12 ZendEngine2/zend.c:1.287.2.13 --- ZendEngine2/zend.c:1.287.2.12 Fri Jul 22 03:33:27 2005 +++ ZendEngine2/zend.c Tue Sep 20 07:38:37 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.287.2.12 2005/07/22 07:33:27 dmitry Exp $ */ +/* $Id: zend.c,v 1.287.2.13 2005/09/20 11:38:37 tony2001 Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -126,7 +126,7 @@ if (is_object) { char *prop_name, *class_name; - zend_unmangle_property_name(string_key, &class_name, &prop_name); + zend_unmangle_property_name_ex(string_key, str_len, &class_name, &prop_name); ZEND_PUTS(prop_name); if (class_name) { if (class_name[0]=='*') { http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.652.2.51&r2=1.652.2.52&ty=u Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.652.2.51 ZendEngine2/zend_execute.c:1.652.2.52 --- ZendEngine2/zend_execute.c:1.652.2.51 Mon Sep 19 12:02:44 2005 +++ ZendEngine2/zend_execute.c Tue Sep 20 07:38:37 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.652.2.51 2005/09/19 16:02:44 dmitry Exp $ */ +/* $Id: zend_execute.c,v 1.652.2.52 2005/09/20 11:38:37 tony2001 Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -3908,7 +3908,7 @@ zend_hash_move_forward(fe_ht); } while (key_type != HASH_KEY_IS_STRING || zend_check_property_access(zobj, str_key TSRMLS_CC) != SUCCESS); - zend_unmangle_property_name(str_key, &class_name, &prop_name); + zend_unmangle_property_name_ex(str_key, str_key_len, &class_name, &prop_name); str_key_len = strlen(prop_name); str_key = estrndup(prop_name, str_key_len); str_key_len++;
« previous php.zend-engine.cvs (#4152) next »