Edit report at https://bugs.php.net/bug.php?id=65028&edit=1

 ID:                 65028
 Updated by:         s...@php.net
 Reported by:        matthias dot burtscher at fusonic dot net
 Summary:            Phar::buildFromDirectory creates corrupt archives
                     for some specific contents
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            PHAR related
 Operating System:   Ubuntu 13.04, Windows 7
 PHP Version:        5.3.x, 5.4.x, 5.5.x
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of stas
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=f8efdc2b4bca2a8f7e57aae36a01df044ba3d0b5
Log: fix bug #65028     Phar::buildFromDirectory creates corrupt archives for 
some specific contents


Previous Comments:
------------------------------------------------------------------------
[2013-07-22 08:02:19] s...@php.net

Matthias, please check if https://github.com/php/php-src/pull/392 fixes your 
problem?

------------------------------------------------------------------------
[2013-07-22 07:27:49] s...@php.net

This is a funny one. Seems to be because phar writes the archive this way:

<?php
// code code code
__HALT_COMPILER(); ?>METADATA_HEADER

Where METADATA_HEADER contains phar metadata, first 4 bytes being metadata 
length. However, when phar reads the file, it checks if "__HALT_COMPILER(); ?>" 
is followed by \r, and if there's \r it also looks for \n. Now imagine what 
happens if metadata length is such that its first byte is 0x0D, but second byte 
is not 0x0A? Phar file is not readable anymore.

------------------------------------------------------------------------
[2013-06-28 05:59:09] matthias dot burtscher at fusonic dot net

I managed to recreate the issue and submitted a test case right here on GitHub:
https://github.com/php/php-src/pull/371

------------------------------------------------------------------------
[2013-06-27 11:59:34] matthias dot burtscher at fusonic dot net

Re-tested with the latest PHP 5.5.0 release, still not working.

------------------------------------------------------------------------
[2013-06-13 14:10:01] matthias dot burtscher at fusonic dot net

This one will result in the same corrupt phar archive:
$phar = new Phar("test.phar");
$iterator = new RecursiveIteratorIterator(new 
RecursiveDirectoryIterator("/tmp/test/content", FilesystemIterator::SKIP_DOTS));
$phar->buildFromIterator($iterator, "/tmp/test/content");
$phar->compress(Phar::GZ);

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=65028


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65028&edit=1

Reply via email to