]> granicus.if.org Git - php/commitdiff
don't copy contents of linked/mounted files when converting an archive, and be sure...
authorGreg Beaver <cellog@php.net>
Sun, 11 May 2008 22:45:03 +0000 (22:45 +0000)
committerGreg Beaver <cellog@php.net>
Sun, 11 May 2008 22:45:03 +0000 (22:45 +0000)
ext/phar/phar_object.c
ext/phar/tests/phar_mount.phpt

index 8c5bfb12cc50e98ba594ed1afbacc4d61dcc46a5..3b5ae23e0d3d50a9382b9da3576ac2625651a0d9 100755 (executable)
@@ -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;
index 90386ffd097b26a4215e6c1177ad9e7245b22abb..4578b3a33debe5c83a172f66b0f8fa9e5c5ef38f 100644 (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===
\ No newline at end of file