Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

[2013-06-13 14:10 UTC] 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);

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.