cvs: ZendEngine2 / zend.c zend_builtin_functions.c zend_compile.c zend_compile.h zend_object_handlers.c zend_object_handlers.h zend_vm_def.h
zend_vm_execute.h

From: Date: Mon, 24 Jul 2006 17:51:41 +0000
Subject: cvs: ZendEngine2 / zend.c zend_builtin_functions.c zend_compile.c zend_compile.h zend_object_handlers.c zend_object_handlers.h zend_vm_def.h
zend_vm_execute.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-5123@lists.php.net to get a copy of this message
helly Mon Jul 24 17:51:41 2006 UTC Modified files: /ZendEngine2 zend.c zend_builtin_functions.c zend_compile.c zend_compile.h zend_object_handlers.c zend_object_handlers.h zend_vm_def.h zend_vm_execute.h Log: - Fix for #34505 and repated (improved version of what is in 5.2, 5.1)

http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.367&r2=1.368&diff_format=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.367 ZendEngine2/zend.c:1.368 --- ZendEngine2/zend.c:1.367 Wed Jul 19 06:33:07 2006 +++ ZendEngine2/zend.c Mon Jul 24 17:51:40 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.367 2006/07/19 06:33:07 tony2001 Exp $ */ +/* $Id: zend.c,v 1.368 2006/07/24 17:51:40 helly Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -239,7 +239,7 @@ if (is_object) { zstr prop_name, class_name; - zend_u_unmangle_property_name(ztype, string_key, &class_name, &prop_name); + zend_u_unmangle_property_name(ztype, string_key, str_len - 1, &class_name, &prop_name); if (class_name.v) { if (class_name.s[0]=='*') { http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.320&r2=1.321&diff_format=u Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.320 ZendEngine2/zend_builtin_functions.c:1.321 --- ZendEngine2/zend_builtin_functions.c:1.320 Thu Jul 20 07:30:14 2006 +++ ZendEngine2/zend_builtin_functions.c Mon Jul 24 17:51:41 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.320 2006/07/20 07:30:14 tony2001 Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.321 2006/07/24 17:51:41 helly Exp $ */ #include "zend.h" #include "zend_API.h" @@ -768,7 +768,7 @@ key_type = zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos); zend_hash_move_forward_ex(properties, &pos); - zend_u_unmangle_property_name(key_type, key, &class_name, &prop_name); + zend_u_unmangle_property_name(key_type, key, key_len-1, &class_name, &prop_name); if (class_name.v) { /* UTODO: Fix this to support Unicode */ if (class_name.s[0] != '*' && strcmp(class_name.s, ce->name.s)) { @@ -862,7 +862,7 @@ while (zend_hash_get_current_data_ex(properties, (void **) &value, &pos) == SUCCESS) { if (zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos) == (UG(unicode)?HASH_KEY_IS_UNICODE:HASH_KEY_IS_STRING)) { - zend_u_unmangle_property_name(UG(unicode)?IS_UNICODE:IS_STRING, key, &class_name, &prop_name); + zend_u_unmangle_property_name(UG(unicode)?IS_UNICODE:IS_STRING, key, key_len-1, &class_name, &prop_name); if (class_name.v == NULL) { /* Not separating references */ (*value)->refcount++; @@ -1027,7 +1027,7 @@ if (property_info->flags & ZEND_ACC_PUBLIC) { RETURN_TRUE; } - zend_u_unmangle_property_name(Z_TYPE_PP(property), property_info->name, &class_name, &prop_name); + zend_u_unmangle_property_name(Z_TYPE_PP(property), property_info->name, property_info->name_length, &class_name, &prop_name); /* UTODO: Fix this??? */ if (class_name.s[0] == '*') { if (instanceof_function(EG(scope), ce TSRMLS_CC)) { http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.718&r2=1.719&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.718 ZendEngine2/zend_compile.c:1.719 --- ZendEngine2/zend_compile.c:1.718 Tue Jul 18 09:08:05 2006 +++ ZendEngine2/zend_compile.c Mon Jul 24 17:51:41 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.718 2006/07/18 09:08:05 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.719 2006/07/24 17:51:41 helly Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -2252,7 +2252,7 @@ if (Z_TYPE_PP(new_prop) != IS_NULL && Z_TYPE_PP(prop) != IS_NULL) { zstr prop_name, tmp; - zend_u_unmangle_property_name(utype, child_info->name, &tmp, &prop_name); + zend_u_unmangle_property_name(utype, child_info->name, child_info->name_length, &tmp, &prop_name); zend_error(E_COMPILE_ERROR, "Cannot change initial value of property static protected %v::$%v in class %v", parent_ce->name, prop_name, ce->name); } @@ -3077,36 +3077,79 @@ } } -ZEND_API void zend_unmangle_property_name(char *mangled_property, char **class_name, char **prop_name) +static int zend_strnlen(const char* s, int maxlen) { - *prop_name = *class_name = NULL; + int len = 0; + while (*s++ && maxlen--) len++; + return len; +} + +static int zend_u_strnlen(const UChar* s, int maxlen) +{ + int len = 0; + while (*s++ && maxlen--) len++; + return len; +} + +ZEND_API int zend_unmangle_property_name(char *mangled_property, int len, char **class_name, char **prop_name) +{ + int class_name_len; + + *class_name = NULL; if (mangled_property[0]!=0) { *prop_name = mangled_property; - return; + return SUCCESS; + } + if (len < 3) { + zend_error(E_NOTICE, "Illegal member variable name"); + *prop_name = mangled_property; + return FAILURE; } + class_name_len = zend_strnlen(mangled_property+1, --len - 1) + 1; + if (class_name_len >= len || mangled_property[class_name_len]!=0) { + zend_error(E_NOTICE, "Corrupt member variable name"); + *prop_name = mangled_property; + return FAILURE; + } *class_name = mangled_property+1; - *prop_name = (*class_name)+strlen(*class_name)+1; + *prop_name = (*class_name)+class_name_len; + return SUCCESS; } -ZEND_API void zend_u_unmangle_property_name(zend_uchar type, zstr mangled_property, zstr *class_name, zstr *prop_name) +ZEND_API int zend_u_unmangle_property_name(zend_uchar type, zstr mangled_property, int len, zstr *class_name, zstr *prop_name) { if (type == IS_UNICODE) { - prop_name->v = class_name->v = NULL; + int class_name_len; + + class_name->v = NULL; if ((mangled_property.u)[0]!=0) { *prop_name = mangled_property; - return; + return SUCCESS; + } + if (len < 3) { + zend_error(E_NOTICE, "Illegal member variable name"); + *prop_name = mangled_property; + return FAILURE; + } + + class_name_len = zend_u_strnlen(mangled_property.u+1, --len - 1) + 1; + if (class_name_len >= len || mangled_property.u[class_name_len]!=0) { + zend_error(E_NOTICE, "Corrupt member variable name"); + *prop_name = mangled_property; + return FAILURE; } class_name->u = mangled_property.u + 1; - prop_name->u = class_name->u + u_strlen(class_name->u)+1; + prop_name->u = class_name->u + class_name_len+1; if (class_name->u[0] == '*') { class_name->s = "*"; } + return SUCCESS; } else { - zend_unmangle_property_name(mangled_property.s, &class_name->s, &prop_name->s); + return zend_unmangle_property_name(mangled_property.s, len, &class_name->s, &prop_name->s); } } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.h?r1=1.344&r2=1.345&diff_format=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.344 ZendEngine2/zend_compile.h:1.345 --- ZendEngine2/zend_compile.h:1.344 Tue Jul 18 17:52:44 2006 +++ ZendEngine2/zend_compile.h Mon Jul 24 17:51:41 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.344 2006/07/18 17:52:44 andrei Exp $ */ +/* $Id: zend_compile.h,v 1.345 2006/07/24 17:51:41 helly Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -548,10 +548,10 @@ void zend_class_add_ref(zend_class_entry **ce); 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 int zend_unmangle_property_name(char *mangled_property, int len, char **prop_name, char **class_name); ZEND_API void zend_u_mangle_property_name(zstr *dest, int *dest_length, zend_uchar type, zstr src1, int src1_length, zstr src2, int src2_length, int internal); -ZEND_API void zend_u_unmangle_property_name(zend_uchar type, zstr mangled_property, zstr *prop_name, zstr *class_name); +ZEND_API int zend_u_unmangle_property_name(zend_uchar type, zstr mangled_property, int len, zstr *prop_name, zstr *class_name); #define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.171&r2=1.172&diff_format=u Index: ZendEngine2/zend_object_handlers.c diff -u ZendEngine2/zend_object_handlers.c:1.171 ZendEngine2/zend_object_handlers.c:1.172 --- ZendEngine2/zend_object_handlers.c:1.171 Fri Jul 21 10:32:41 2006 +++ ZendEngine2/zend_object_handlers.c Mon Jul 24 17:51:41 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.c,v 1.171 2006/07/21 10:32:41 dmitry Exp $ */ +/* $Id: zend_object_handlers.c,v 1.172 2006/07/24 17:51:41 helly Exp $ */ #include "zend.h" #include "zend_globals.h" @@ -246,13 +246,13 @@ } -ZEND_API int zend_check_property_access(zend_object *zobj, zend_uchar utype, zstr prop_info_name TSRMLS_DC) +ZEND_API int zend_check_property_access(zend_object *zobj, zend_uchar utype, zstr prop_info_name, int prop_info_name_len TSRMLS_DC) { zend_property_info *property_info; zstr class_name, prop_name; zval member; - zend_u_unmangle_property_name(utype, prop_info_name, &class_name, &prop_name); + zend_u_unmangle_property_name(utype, prop_info_name, prop_info_name_len, &class_name, &prop_name); if (utype == IS_UNICODE) { ZVAL_UNICODE(&member, prop_name.u, 0); } else { http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.h?r1=1.58&r2=1.59&diff_format=u Index: ZendEngine2/zend_object_handlers.h diff -u ZendEngine2/zend_object_handlers.h:1.58 ZendEngine2/zend_object_handlers.h:1.59 --- ZendEngine2/zend_object_handlers.h:1.58 Wed Jul 5 11:41:09 2006 +++ ZendEngine2/zend_object_handlers.h Mon Jul 24 17:51:41 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_object_handlers.h,v 1.58 2006/07/05 11:41:09 tony2001 Exp $ */ +/* $Id: zend_object_handlers.h,v 1.59 2006/07/24 17:51:41 helly Exp $ */ #ifndef ZEND_OBJECT_HANDLERS_H #define ZEND_OBJECT_HANDLERS_H @@ -153,7 +153,7 @@ ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope); -ZEND_API int zend_check_property_access(zend_object *zobj, zend_uchar utype, zstr prop_info_name TSRMLS_DC); +ZEND_API int zend_check_property_access(zend_object *zobj, zend_uchar utype, zstr prop_info_name, int prop_info_name_len TSRMLS_DC); ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS); END_EXTERN_C() http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h?r1=1.127&r2=1.128&diff_format=u Index: ZendEngine2/zend_vm_def.h diff -u ZendEngine2/zend_vm_def.h:1.127 ZendEngine2/zend_vm_def.h:1.128 --- ZendEngine2/zend_vm_def.h:1.127 Fri Jul 21 11:13:24 2006 +++ ZendEngine2/zend_vm_def.h Mon Jul 24 17:51:41 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_vm_def.h,v 1.127 2006/07/21 11:13:24 dmitry Exp $ */ +/* $Id: zend_vm_def.h,v 1.128 2006/07/24 17:51:41 helly Exp $ */ /* If you change this file, please regenerate the zend_vm_execute.h and * zend_vm_opcodes.h files by running: @@ -3242,7 +3242,7 @@ key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); if (key_type != HASH_KEY_NON_EXISTANT && - zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key TSRMLS_CC) == SUCCESS) { + zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, str_key_len-1 TSRMLS_CC) == SUCCESS) { break; } zend_hash_move_forward(fe_ht); @@ -3301,9 +3301,9 @@ key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); zend_hash_move_forward(fe_ht); - } while (key_type == HASH_KEY_NON_EXISTANT || zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key TSRMLS_CC) != SUCCESS); + } while (key_type == HASH_KEY_NON_EXISTANT || zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, str_key_len-1 TSRMLS_CC) != SUCCESS); if (use_key) { - zend_u_unmangle_property_name(key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, &class_name, &prop_name); + zend_u_unmangle_property_name(key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, str_key_len-1, &class_name, &prop_name); if (key_type == HASH_KEY_IS_UNICODE) { str_key_len = u_strlen(prop_name.u); str_key.u = eustrndup(prop_name.u, str_key_len); http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.131&r2=1.132&diff_format=u Index: ZendEngine2/zend_vm_execute.h diff -u ZendEngine2/zend_vm_execute.h:1.131 ZendEngine2/zend_vm_execute.h:1.132 --- ZendEngine2/zend_vm_execute.h:1.131 Fri Jul 21 11:13:24 2006 +++ ZendEngine2/zend_vm_execute.h Mon Jul 24 17:51:41 2006 @@ -2174,7 +2174,7 @@ key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); if (key_type != HASH_KEY_NON_EXISTANT && - zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key TSRMLS_CC) == SUCCESS) { + zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, str_key_len-1 TSRMLS_CC) == SUCCESS) { break; } zend_hash_move_forward(fe_ht); @@ -4752,7 +4752,7 @@ key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); if (key_type != HASH_KEY_NON_EXISTANT && - zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key TSRMLS_CC) == SUCCESS) { + zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, str_key_len-1 TSRMLS_CC) == SUCCESS) { break; } zend_hash_move_forward(fe_ht); @@ -7927,7 +7927,7 @@ key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); if (key_type != HASH_KEY_NON_EXISTANT && - zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key TSRMLS_CC) == SUCCESS) { + zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, str_key_len-1 TSRMLS_CC) == SUCCESS) { break; } zend_hash_move_forward(fe_ht); @@ -7986,9 +7986,9 @@ key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); zend_hash_move_forward(fe_ht); - } while (key_type == HASH_KEY_NON_EXISTANT || zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key TSRMLS_CC) != SUCCESS); + } while (key_type == HASH_KEY_NON_EXISTANT || zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, str_key_len-1 TSRMLS_CC) != SUCCESS); if (use_key) { - zend_u_unmangle_property_name(key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, &class_name, &prop_name); + zend_u_unmangle_property_name(key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, str_key_len-1, &class_name, &prop_name); if (key_type == HASH_KEY_IS_UNICODE) { str_key_len = u_strlen(prop_name.u); str_key.u = eustrndup(prop_name.u, str_key_len); @@ -20902,7 +20902,7 @@ key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); if (key_type != HASH_KEY_NON_EXISTANT && - zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key TSRMLS_CC) == SUCCESS) { + zend_check_property_access(zobj, key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, str_key_len-1 TSRMLS_CC) == SUCCESS) { break; } zend_hash_move_forward(fe_ht);
« previous php.zend-engine.cvs (#5123) next »