mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.4'
* PHP-8.4: Use-after-free in extract() with EXTR_REFS
This commit is contained in:
commit
e4e663ced4
2 changed files with 26 additions and 1 deletions
|
@ -1957,8 +1957,10 @@ static zend_long php_extract_ref_overwrite(zend_array *arr, zend_array *symbol_t
|
|||
} else {
|
||||
ZVAL_MAKE_REF_EX(entry, 2);
|
||||
}
|
||||
zval_ptr_dtor(orig_var);
|
||||
zval garbage;
|
||||
ZVAL_COPY_VALUE(&garbage, orig_var);
|
||||
ZVAL_REF(orig_var, Z_REF_P(entry));
|
||||
zval_ptr_dtor(&garbage);
|
||||
} else {
|
||||
if (Z_ISREF_P(entry)) {
|
||||
Z_ADDREF_P(entry);
|
||||
|
|
23
ext/standard/tests/gh18209.phpt
Normal file
23
ext/standard/tests/gh18209.phpt
Normal file
|
@ -0,0 +1,23 @@
|
|||
--TEST--
|
||||
GH-18209: Use-after-free in extract() with EXTR_REFS
|
||||
--CREDITS--
|
||||
Noam Rathaus (nrathaus)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class C {
|
||||
public function __destruct() {
|
||||
var_dump($GLOBALS['b']);
|
||||
$GLOBALS['b'] = 43;
|
||||
}
|
||||
}
|
||||
|
||||
$b = new C;
|
||||
$array = ['b' => 42];
|
||||
extract($array, EXTR_REFS);
|
||||
var_dump($b);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(42)
|
||||
int(43)
|
Loading…
Add table
Add a link
Reference in a new issue