Skip to content

Commit 6c51f70

Browse files
committed
fix #19752 missing dup of fname field in phar_convert_to_other
1 parent 1ac91f5 commit 6c51f70

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ext/phar/phar_object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,7 @@ static zend_object *phar_convert_to_other(phar_archive_data *source, int convert
22662266
zend_throw_exception_ex(phar_ce_PharException, 0, "unable to create temporary file");
22672267
return NULL;
22682268
}
2269-
phar->fname = source->fname;
2269+
phar->fname = estrndup(source->fname, source->fname_len);
22702270
phar->fname_len = source->fname_len;
22712271
phar->is_temporary_alias = source->is_temporary_alias;
22722272
phar->alias = source->alias;

ext/phar/tests/gh19752.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
GH-19752 (missing dup in phar_convert_to_other)
3+
--EXTENSIONS--
4+
phar
5+
--FILE--
6+
<?php
7+
$phar = new PharData('test.1');
8+
9+
try {
10+
$phar->decompress("*");
11+
} catch (Exception $ex) {
12+
var_dump($ex->getMessage());
13+
}
14+
?>
15+
--EXPECTF--
16+
string(%d) "data phar converted from "%stest.1" has invalid extension *"

0 commit comments

Comments
 (0)