mirror of
https://github.com/php/php-src.git
synced 2026-04-23 07:58:20 +02:00
Fixed bug #63980 (object members get trimmed by zero bytes)
This commit is contained in:
@@ -2,6 +2,9 @@ PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? 201?, PHP 5.5.0 Alpha 3
|
||||
|
||||
- Core:
|
||||
. Fixed bug #63980 (object members get trimmed by zero bytes). (Laruence)
|
||||
|
||||
- General improvements:
|
||||
. Fixed bug #63874 (Segfault if php_strip_whitespace has heredoc). (Pierrick)
|
||||
. Fixed bug #63822 (Crash when using closures with ArrayAccess).
|
||||
|
||||
+3
-2
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
+16
-4
@@ -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;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
+3
-1
@@ -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
|
||||
|
||||
+1
-2
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user