diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 9982074f73a81..4b294c13fb274 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -2266,7 +2266,7 @@ static zend_object *phar_convert_to_other(phar_archive_data *source, int convert zend_throw_exception_ex(phar_ce_PharException, 0, "unable to create temporary file"); return NULL; } - phar->fname = source->fname; + phar->fname = estrndup(source->fname, source->fname_len); phar->fname_len = source->fname_len; phar->is_temporary_alias = source->is_temporary_alias; phar->alias = source->alias; diff --git a/ext/phar/tests/gh19752.phpt b/ext/phar/tests/gh19752.phpt new file mode 100644 index 0000000000000..c6ffab5b06860 --- /dev/null +++ b/ext/phar/tests/gh19752.phpt @@ -0,0 +1,16 @@ +--TEST-- +GH-19752 (missing dup in phar_convert_to_other) +--EXTENSIONS-- +phar +--FILE-- +decompress("*"); +} catch (Exception $ex) { + var_dump($ex->getMessage()); +} +?> +--EXPECTF-- +string(%d) "data phar converted from "%stest.1" has invalid extension *"