From: matthias dot burtscher at fusonic dot net
Operating system: Ubuntu 13.04
PHP version: 5.5.0RC3
Package: PHAR related
Bug Type: Bug
Bug description:Phar::buildFromDirectory creates corrupt archives for some
specific contents
Description:
------------
When creating a Phar archive with a very simple Phar::createFromDirectory()
call
(see test script) the generated archive is corrupt sometimes, depending on
the
contents packed into the Phar.
I CAN PROVIDE THE TEST CONTENTS TO A DEVELOPER BUT NOT TO THE PUBLIC.
Opening the Phar will cause a Fatal error. Adding an additional empty file
(see
test script) to the archive fixes the problem. Sometimes a second empty
file has
to be added, sometimes a third one.
Tested PHP versions:
- 5.3.26
- 5.4.16
- 5.5.0 RC3
Configure line (all versions):
'./configure'
'--prefix=/opt/php/bin/php-5.3.26'
'--with-gd'
'--with-ldap=/usr'
'--with-mysql'
'--with-mssql'
'--with-pdo-mysql'
'--with-pdo-dblib'
'--with-pdo-pgsql'
'--with-pgsql'
'--with-config-file-path=/opt/php/bin/php-5.3.26/etc'
'--enable-mbstring'
'--with-mcrypt'
'--with-openssl'
'--with-curl'
'--with-zlib'
'--with-libdir=lib/x86_64-linux-gnu'
'--with-jpeg-dir'
'--with-png-dir'
Test script:
---------------
// Corrupt
$phar = new Phar("test.phar");
$phar->buildFromDirectory("content");
$phar->compress(Phar::GZ);
// Working (only difference is adding the empty file)
$phar = new Phar("test.phar");
$phar->buildFromDirectory("content");
$phar->addFromString("an-empty-file", "");
$phar->compress(Phar::GZ);
Expected result:
----------------
Working phar archive which can be opened with "new Phar('test.phar')".
Actual result:
--------------
Fatal error: Uncaught exception 'UnexpectedValueException' with message
'internal
corruption of phar "/tmp/test/test.phar" (truncated manifest at stub end)'
--
Edit bug report at https://bugs.php.net/bug.php?id=65028&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=65028&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=65028&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=65028&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=65028&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=65028&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=65028&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=65028&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=65028&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=65028&r=support
Expected behavior: https://bugs.php.net/fix.php?id=65028&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=65028&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=65028&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=65028&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65028&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=65028&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=65028&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=65028&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65028&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=65028&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=65028&r=mysqlcfg