don't copy contents of linked/mounted files when converting an archive, and be sure to dupe mounted value

This commit is contained in:
Greg Beaver 2008-05-11 22:45:03 +00:00
parent 92f0dc842f
commit ad1be25d8c
2 changed files with 24 additions and 6 deletions

View File

@ -1959,6 +1959,11 @@ static zval *phar_convert_to_other(phar_archive_data *source, int convert, char
newentry = *entry;
if (newentry.link) {
newentry.link = estrdup(newentry.link);
goto no_copy;
}
if (newentry.tmp) {
newentry.tmp = estrdup(newentry.tmp);
goto no_copy;
}
if (FAILURE == phar_copy_file_contents(&newentry, phar->fp TSRMLS_CC)) {
zend_hash_destroy(&(phar->manifest));
@ -1967,6 +1972,7 @@ static zval *phar_convert_to_other(phar_archive_data *source, int convert, char
/* exception already thrown */
return NULL;
}
no_copy:
newentry.filename = estrndup(newentry.filename, newentry.filename_len);
if (newentry.metadata) {
zval *t;

View File

@ -6,8 +6,9 @@ Phar: Phar::mount
phar.readonly=0
--FILE--
<?php
$fname = dirname(__FILE__) . '/tempmanifest1.phar.php';
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$pname = 'phar://' . $fname;
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
$a = new Phar($fname);
$a['index.php'] = '<?php
@ -29,13 +30,24 @@ include "index.php";
__HALT_COMPILER();');
Phar::mount($pname . '/testit1', __FILE__);
include $fname;
// test copying of a phar with mounted entries
$b = $a->convertToExecutable(Phar::TAR);
$b->setStub('<?php
set_include_path("phar://" . __FILE__);
include "index.php";
__HALT_COMPILER();');
try {
include $fname2;
} catch (Exception $e) {
echo $e->getMessage(),"\n";
}
?>
===DONE===
--CLEAN--
<?php
@unlink(dirname(__FILE__) . '/tempmanifest1.phar.php');
?>
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
--EXPECTF--
Mounting of testit to %sphar_mount.php within phar %stempmanifest1.phar.php failed
Can only mount internal paths within a phar archive, use a relative path instead of "phar://%stempmanifest1.phar.php/testit1"
Mounting of testit to %sphar_mount.php within phar %sphar_mount.phar.php failed
Can only mount internal paths within a phar archive, use a relative path instead of "phar://%sphar_mount.phar.php/testit1"
Mounting of testit to %sphar_mount.php within phar %sphar_mount.phar.tar failed
===DONE===