com php-src: Fixed bug #70959 (ArrayObject unserialize does not restore protected fields): Zend/zend_API.c ext/spl/tests/bug7 0959.phpt
| From: | Anatol Belski | Date: | Wed, 25 Nov 2015 02:11:26 +0000 |
| Subject: | com php-src: Fixed bug #70959 (ArrayObject unserialize does not restore protected fields): Zend/zend_API.c ext/spl/tests/bug7 0959.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90013@lists.php.net to get a copy of this message | ||
Commit: 254e70948437b5a412630784e7eb4b2a40147e4c
Author: Xinchen Hui <laruence@gmail.com> Mon, 23 Nov 2015 23:15:33 +0800
Committer: Anatol Belski <ab@php.net> Wed, 25 Nov 2015 03:11:26 +0100
Parents: 8b52a8edbe6822c4d36b31ef54126e67231c2519
Branches: PHP-7.0.0
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=254e70948437b5a412630784e7eb4b2a40147e4c
Log:
Fixed bug #70959 (ArrayObject unserialize does not restore protected fields)
Bugs:
https://bugs.php.net/70959
Changed paths:
M Zend/zend_API.c
A ext/spl/tests/bug70959.phpt
Diff:
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 5a488f7..0e6d89f 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -1219,8 +1219,20 @@ ZEND_API void object_properties_load(zend_object *object, HashTable
*properties)
zend_property_info *property_info;
ZEND_HASH_FOREACH_KEY_VAL(properties, h, key, prop) {
- if(key) {
- property_info = zend_get_property_info(object->ce, key, 1);
+ if (key) {
+ if (ZSTR_VAL(key)[0] == '\0') {
+ const char *class_name, *prop_name;
+ size_t prop_name_len;
+ if (zend_unmangle_property_name_ex(key, &class_name, &prop_name, &prop_name_len) ==
SUCCESS) {
+ zend_string *pname = zend_string_init(prop_name, prop_name_len, 0);
+ property_info = zend_get_property_info(object->ce, pname, 1);
+ zend_string_release(pname);
+ } else {
+ property_info = ZEND_WRONG_PROPERTY_INFO;
+ }
+ } else {
+ property_info = zend_get_property_info(object->ce, key, 1);
+ }
if (property_info != ZEND_WRONG_PROPERTY_INFO &&
property_info &&
(property_info->flags & ZEND_ACC_STATIC) == 0) {
diff --git a/ext/spl/tests/bug70959.phpt b/ext/spl/tests/bug70959.phpt
new file mode 100644
index 0000000..3fd5007
--- /dev/null
+++ b/ext/spl/tests/bug70959.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #70959 (ArrayObject unserialize does not restore protected fields)
+--FILE--
+<?php
+class testObject extends ArrayObject {
+ protected $test;
+
+ public function getTest() {
+ return $this->test;
+ }
+
+ public function setTest($test) {
+ $this->test = $test;
+ }
+}
+
+$obj = new testObject();
+$obj->setTest('test');
+var_dump($obj->getTest());
+$obj2 = unserialize(serialize($obj));
+var_dump($obj2->getTest());
+--EXPECTF--
+string(4) "test"
+string(4) "test"