mirror of
https://github.com/php/php-src.git
synced 2025-08-17 06:28:50 +02:00
Fix bug #69958 - Segfault in Phar::convertToData on invalid file
This commit is contained in:
parent
29533ae528
commit
bf58162ddf
3 changed files with 50 additions and 34 deletions
|
@ -2419,7 +2419,9 @@ no_copy:
|
||||||
zend_hash_destroy(&(phar->manifest));
|
zend_hash_destroy(&(phar->manifest));
|
||||||
zend_hash_destroy(&(phar->mounted_dirs));
|
zend_hash_destroy(&(phar->mounted_dirs));
|
||||||
zend_hash_destroy(&(phar->virtual_dirs));
|
zend_hash_destroy(&(phar->virtual_dirs));
|
||||||
|
if (phar->fp) {
|
||||||
php_stream_close(phar->fp);
|
php_stream_close(phar->fp);
|
||||||
|
}
|
||||||
efree(phar->fname);
|
efree(phar->fname);
|
||||||
efree(phar);
|
efree(phar);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
14
ext/phar/tests/bug69958.phpt
Normal file
14
ext/phar/tests/bug69958.phpt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
--TEST--
|
||||||
|
Phar: bug #69958: Segfault in Phar::convertToData on invalid file
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
$tarphar = new PharData(__DIR__.'/bug69958.tar');
|
||||||
|
$phar = $tarphar->convertToData(Phar::TAR);
|
||||||
|
--EXPECTF--
|
||||||
|
Fatal error: Uncaught exception 'BadMethodCallException' with message 'phar "%s/bug69958.tar" exists and must be unlinked prior to conversion' in %s/bug69958.php:%d
|
||||||
|
Stack trace:
|
||||||
|
#0 %s/bug69958.php(%d): PharData->convertToData(%d)
|
||||||
|
#1 {main}
|
||||||
|
thrown in %s/bug69958.php on line %d
|
BIN
ext/phar/tests/bug69958.tar
Normal file
BIN
ext/phar/tests/bug69958.tar
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue