com php-src: Fixed bug #73900: NEWS Zend/tests/bug73900.phpt Zend/zend_execute.c
| From: | Nikita Popov | Date: | Sun, 25 Jun 2017 17:48:17 +0000 |
| Subject: | com php-src: Fixed bug #73900: NEWS Zend/tests/bug73900.phpt Zend/zend_execute.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98213@lists.php.net to get a copy of this message | ||
Commit: 2fddc4a7f1588239939a509781706c084939e09f
Author: Nikita Popov <nikita.ppv@gmail.com> Sun, 25 Jun 2017 19:48:17 +0200
Parents: de66e80d757f2a89fa16ee436d89ecc428f369a9
Branches: PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2fddc4a7f1588239939a509781706c084939e09f
Log:
Fixed bug #73900
Bugs:
https://bugs.php.net/73900
Changed paths:
M NEWS
A Zend/tests/bug73900.phpt
M Zend/zend_execute.c
Diff:
diff --git a/NEWS b/NEWS
index d0ddb65..58e7654 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ PHP NEWS
. Fixed bug #74780 (parse_url() borken when query string contains colon).
(jhdxr)
. Fixed bug #74761 (Unary operator expected error on some systems). (petk)
+ . Fixed bug #73900 (Use After Free in unserialize() SplFixedArray). (nikic)
- SPL:
. Fixed bug #73471 (PHP freezes with AppendIterator). (jhdxr)
diff --git a/Zend/tests/bug73900.phpt b/Zend/tests/bug73900.phpt
new file mode 100644
index 0000000..fbd5b86
--- /dev/null
+++ b/Zend/tests/bug73900.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #73900: Use After Free in unserialize() SplFixedArray
+--FILE--
+<?php
+
+$a = new stdClass;
+$b = new SplFixedArray(1);
+$b[0] = $a;
+$c = &$b[0];
+var_dump($c);
+
+?>
+--EXPECT--
+object(stdClass)#1 (0) {
+}
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index a5d09f4..a4fb7ae 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1758,16 +1758,9 @@ convert_to_array:
zend_error(E_NOTICE, "Indirect modification of overloaded element of %s has no
effect", ZSTR_VAL(ce->name));
} else if (EXPECTED(retval && Z_TYPE_P(retval) != IS_UNDEF)) {
if (!Z_ISREF_P(retval)) {
- if (Z_REFCOUNTED_P(retval) &&
- Z_REFCOUNT_P(retval) > 1) {
- if (Z_TYPE_P(retval) != IS_OBJECT) {
- Z_DELREF_P(retval);
- ZVAL_DUP(result, retval);
- retval = result;
- } else {
- ZVAL_COPY_VALUE(result, retval);
- retval = result;
- }
+ if (result != retval) {
+ ZVAL_COPY(result, retval);
+ retval = result;
}
if (Z_TYPE_P(retval) != IS_OBJECT) {
zend_class_entry *ce = Z_OBJCE_P(container);