Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/phar/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
entry->is_deleted = 1;
entry->fp = NULL;
ZVAL_UNDEF(&entry->metadata_tracker.val);
entry->metadata_tracker.str = NULL;
entry->link = entry->tmp = NULL;
source = entry;

Expand Down
25 changes: 25 additions & 0 deletions ext/phar/tests/gh25090.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
GH-25090 (Use-after-free in phar_wrapper_rename() with entry metadata)
--EXTENSIONS--
phar
--INI--
phar.readonly=0
--FILE--
<?php
$fname = __DIR__ . '/gh25090.phar';
$phar = new Phar($fname);
$phar['a'] = 'x';
$phar['a']->setMetadata(['k' => 'v']);
rename('phar://' . $fname . '/a', 'phar://' . $fname . '/b');
$phar['c'] = 'y';
var_dump($phar['b']->getMetadata());
?>
--CLEAN--
<?php
@unlink(__DIR__ . '/gh25090.phar');
?>
--EXPECT--
array(1) {
["k"]=>
string(1) "v"
}
Loading