php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #63980
Patch bug63980.patch revision 2013-01-14 03:44 UTC by laruence@php.net

Patch bug63980.patch for *General Issues Bug #63980

Patch version 2013-01-14 03:44 UTC

Return to Bug #63980 | Download this patch
Patch Revisions:

Developer: laruence@php.net

diff --git a/Zend/zend.c b/Zend/zend.c
index d71d7cb..aad6165 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -158,9 +158,10 @@ static void print_hash(zend_write_func_t write_func, HashTable *ht, int indent,
 			case HASH_KEY_IS_STRING:
 				if (is_object) {
 					const char *prop_name, *class_name;
-					int mangled = zend_unmangle_property_name(string_key, str_len - 1, &class_name, &prop_name);
+					int prop_len;
+					int mangled = zend_unmangle_property_name_ex(string_key, str_len - 1, &class_name, &prop_name, &prop_len);
 
-					ZEND_PUTS_EX(prop_name);
+					ZEND_WRITE_EX(prop_name, prop_len);
 					if (class_name && mangled == SUCCESS) {
 						if (class_name[0]=='*') {
 							ZEND_PUTS_EX(":protected");
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 7bbb047..4d950a2 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -987,7 +987,7 @@ ZEND_FUNCTION(get_object_vars)
 	HashPosition pos;
 	char *key;
 	const char *prop_name, *class_name;
-	uint key_len;
+	uint key_len, prop_len;
 	ulong num_index;
 	zend_object *zobj;
 
@@ -1014,10 +1014,10 @@ ZEND_FUNCTION(get_object_vars)
 	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) == HASH_KEY_IS_STRING) {
 			if (zend_check_property_access(zobj, key, key_len-1 TSRMLS_CC) == SUCCESS) {
-				zend_unmangle_property_name(key, key_len-1, &class_name, &prop_name);
+				zend_unmangle_property_name_ex(key, key_len - 1, &class_name, &prop_name, &prop_len);
 				/* Not separating references */
 				Z_ADDREF_PP(value);
-				add_assoc_zval_ex(return_value, prop_name, strlen(prop_name)+1, *value);
+				add_assoc_zval_ex(return_value, prop_name, prop_len + 1, *value);
 			}
 		}
 		zend_hash_move_forward_ex(properties, &pos);
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 101662c..a5d6add 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -5178,7 +5178,7 @@ static int zend_strnlen(const char* s, int maxlen) /* {{{ */
 }
 /* }}} */
 
-ZEND_API int zend_unmangle_property_name(const char *mangled_property, int len, const char **class_name, const char **prop_name) /* {{{ */
+ZEND_API int zend_unmangle_property_name_ex(const char *mangled_property, int len, const char **class_name, const char **prop_name, int *prop_len) /* {{{ */
 {
 	int class_name_len;
 
@@ -5186,22 +5186,34 @@ ZEND_API int zend_unmangle_property_name(const char *mangled_property, int len,
 
 	if (mangled_property[0]!=0) {
 		*prop_name = mangled_property;
+		if (prop_len) {
+			*prop_len = len;
+		}
 		return SUCCESS;
 	}
 	if (len < 3 || mangled_property[1]==0) {
 		zend_error(E_NOTICE, "Illegal member variable name");
 		*prop_name = mangled_property;
+		if (prop_len) {
+			*prop_len = len;
+		}
 		return FAILURE;
 	}
 
-	class_name_len = zend_strnlen(mangled_property+1, --len - 1) + 1;
+	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;
+		if (prop_len) {
+			*prop_len = len + 1;
+		}
 		return FAILURE;
 	}
-	*class_name = mangled_property+1;
-	*prop_name = (*class_name)+class_name_len;
+	*class_name = mangled_property + 1;
+	*prop_name = (*class_name) + class_name_len;
+	if (prop_len) {
+		*prop_len = len - class_name_len;
+	}
 	return SUCCESS;
 }
 /* }}} */
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index d2ab060..0f58b55 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -671,7 +671,9 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce);
 void zend_class_add_ref(zend_class_entry **ce);
 
 ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, const char *src1, int src1_length, const char *src2, int src2_length, int internal);
-ZEND_API int zend_unmangle_property_name(const char *mangled_property, int mangled_property_len, const char **class_name, const char **prop_name);
+#define zend_unmangle_property_name(mangled_property, mangled_property_len, class_name, prop_name) \
+        zend_unmangle_property_name_ex(mangled_property, mangled_property_len, class_name, prop_name, NULL) 
+ZEND_API int zend_unmangle_property_name_ex(const char *mangled_property, int mangled_property_len, const char **class_name, const char **prop_name, int *prop_len);
 
 #define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor
 #define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 82826c9..3f9cc12 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -4266,8 +4266,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)
 			          zend_check_property_access(zobj, str_key, str_key_len-1 TSRMLS_CC) != SUCCESS));
 			zend_hash_get_pointer(fe_ht, &EX_T(opline->op1.var).fe.fe_pos);
 			if (use_key && key_type != HASH_KEY_IS_LONG) {
-				zend_unmangle_property_name(str_key, str_key_len-1, &class_name, &prop_name);
-				str_key_len = strlen(prop_name);
+				zend_unmangle_property_name_ex(str_key, str_key_len-1, &class_name, &prop_name, &str_key_len);
 				str_key = estrndup(prop_name, str_key_len);
 				str_key_len++;
 			}
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 23f6187..614249f 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -13565,8 +13565,7 @@ static int ZEND_FASTCALL  ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
 			          zend_check_property_access(zobj, str_key, str_key_len-1 TSRMLS_CC) != SUCCESS));
 			zend_hash_get_pointer(fe_ht, &EX_T(opline->op1.var).fe.fe_pos);
 			if (use_key && key_type != HASH_KEY_IS_LONG) {
-				zend_unmangle_property_name(str_key, str_key_len-1, &class_name, &prop_name);
-				str_key_len = strlen(prop_name);
+				zend_unmangle_property_name_ex(str_key, str_key_len-1, &class_name, &prop_name, &str_key_len);
 				str_key = estrndup(prop_name, str_key_len);
 				str_key_len++;
 			}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 10 15:01:28 2024 UTC