mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix GH-17162: zend_array_try_init() with dtor can cause engine UAF
Closes GH-17167.
This commit is contained in:
parent
0a3442fbe6
commit
ee0daa59db
3 changed files with 27 additions and 1 deletions
2
NEWS
2
NEWS
|
@ -4,6 +4,8 @@ PHP NEWS
|
|||
|
||||
- Core:
|
||||
. Fixed bug GH-17106 (ZEND_MATCH_ERROR misoptimization). (ilutov)
|
||||
. Fixed bug GH-17162 (zend_array_try_init() with dtor can cause engine UAF).
|
||||
(nielsdos)
|
||||
|
||||
- DBA:
|
||||
. Skip test if inifile is disabled. (orlitzky)
|
||||
|
|
21
Zend/tests/gh17162.phpt
Normal file
21
Zend/tests/gh17162.phpt
Normal file
|
@ -0,0 +1,21 @@
|
|||
--TEST--
|
||||
GH-17162 (zend_array_try_init() with dtor can cause engine UAF)
|
||||
--FILE--
|
||||
<?php
|
||||
class Test {
|
||||
function __destruct() {
|
||||
global $box;
|
||||
$box->value = null;
|
||||
}
|
||||
}
|
||||
$box = [new Test];
|
||||
// Using getimagesize() for the test because it's always available,
|
||||
// but any function that uses zend_try_array_init() would work.
|
||||
try {
|
||||
getimagesize("dummy", $box);
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Attempt to assign property "value" on null
|
|
@ -1478,7 +1478,10 @@ static zend_always_inline zval *zend_try_array_init_size(zval *zv, uint32_t size
|
|||
}
|
||||
zv = &ref->val;
|
||||
}
|
||||
zval_ptr_dtor(zv);
|
||||
zval garbage;
|
||||
ZVAL_COPY_VALUE(&garbage, zv);
|
||||
ZVAL_NULL(zv);
|
||||
zval_ptr_dtor(&garbage);
|
||||
ZVAL_ARR(zv, arr);
|
||||
return zv;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue