com php-src: Fix #79919: Stack use-after-scope in define(): NEWS Zend/tests/bug79919.phpt Zend/zend_builtin_functions.c
| From: | Christoph Michael Becker | Date: | Fri, 31 Jul 2020 08:54:41 +0000 |
| Subject: | com php-src: Fix #79919: Stack use-after-scope in define(): NEWS Zend/tests/bug79919.phpt Zend/zend_builtin_functions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-112468@lists.php.net to get a copy of this message | ||
Commit: 1e0bc6e30f9fb327cd06383c8290a8afab1e484d
Author: Christoph M. Becker <cmbecker69@gmx.de> Fri, 31 Jul 2020 09:12:22 +0200
Parents: d95c53834cec1570b8f3e836cd514d6ae5901e68
Branches: PHP-7.3 PHP-7..4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1e0bc6e30f9fb327cd06383c8290a8afab1e484d
Log:
Fix #79919: Stack use-after-scope in define()
Instead of the temporary
rv, we use the val_free which is there for
this purpose.
Bugs:
https://bugs.php.net/79919
Changed paths:
M NEWS
A Zend/tests/bug79919.phpt
M Zend/zend_builtin_functions.c
Diff:
diff --git a/NEWS b/NEWS
index 1a5d787307..ebdb9601ee 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ PHP NEWS
. Fixed bug #79806 (realpath() erroneously resolves link to link). (cmb)
. Fixed bug #79895 (PHP_CHECK_GCC_ARG does not allow flags with equal sign).
(Santiago M. Mola)
+ . Fixed bug #79919 (Stack use-after-scope in define()). (cmb)
- LDAP:
. Fixed memory leaks. (ptomulik)
diff --git a/Zend/tests/bug79919.phpt b/Zend/tests/bug79919.phpt
new file mode 100644
index 0000000000..c135722675
--- /dev/null
+++ b/Zend/tests/bug79919.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #79919 (Stack use-after-scope in define())
+--SKIPIF--
+<?php
+if (!extension_loaded('simplexml')) die('skip simplexml extension not
available');
+?>
+--FILE--
+<?php
+$b = error_log(0);
+$b = simplexml_load_string('<xml/>', null, $b);
+define(0, $b);
+?>
+--EXPECT--
+0
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index bc3649a622..468a7c3446 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -882,9 +882,7 @@ repeat:
case IS_OBJECT:
if (Z_TYPE(val_free) == IS_UNDEF) {
if (Z_OBJ_HT_P(val)->get) {
- zval rv;
- val = Z_OBJ_HT_P(val)->get(val, &rv);
- ZVAL_COPY_VALUE(&val_free, val);
+ val = Z_OBJ_HT_P(val)->get(val, &val_free);
goto repeat;
} else if (Z_OBJ_HT_P(val)->cast_object) {
if (Z_OBJ_HT_P(val)->cast_object(val, &val_free, IS_STRING) == SUCCESS) {