php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63802 Hangs on garbage-data after end of archive
Submitted: 2012-12-19 08:49 UTC Modified: 2015-04-26 04:22 UTC
Votes:7
Avg. Score:4.7 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: pecl at xu9 dot de Assigned: cmb (profile)
Status: No Feedback Package: Zip Related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-12-19 08:49 UTC] pecl at xu9 dot de
Description:
------------
I stumbled upon this bug because my import-scripts kept hanging on the same file over and over.

The files itself are created by some kind of Windows CE Appliance. The wrapper from Midnight Commander (written in Perl) seems to have similar problems but it just wont open the file instead of freezing.

Inside the File it seems that the "PK"-Signature is repeating shortly before the end of the archive.

"unzip" commandline utility works and does not find any errors.



Test script:
---------------
<?
// sample-zip at http://xu9.de/test.zip
$zip = new ZipArchive();
$zip->open("test.zip");

print $zip->numFiles . " Files inside\n";flush();
for ($i = 0; $i < $zip->numFiles; $i++) {
    $entry = $zip->getNameIndex($i);
    $zip->extractTo('/tmp');   // HANGS!

    $xml = sprintf("zip://%s#%s", 'test.zip', $entry);

    $fh=fopen($xml,'r'); // ALSO HANGS!
    while (! feof($fh)) $data .= fgets($fh,8192);
    fclose($fh);

    $d = file_get_contents($xml); // ALSO HANGS!
}

?>


Expected result:
----------------
Getting content of file inside

Actual result:
--------------
Freezes

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-01 22:56 UTC] edwardvb at formulaworld dot com
I am experiencing the very same problem... about 1 out of 10 zip-files (usually filled with 1 or max 10 file) hang on the $zip->extractTo() command.

the zip files come from various sources. I don't know how they are created.

my code is quite straightforward:
print "start";
$zip = new ZipArchive();
print "open zipfile";
$zip->open($zipfile);
print "extract";
$zip->extractTo($mydir);
print "finished extracting";    // this line is never printed

during my last test I have a 318kB Zipfile, containing ONE xml file of 5060kB. The xml file is created in $mydir, but has a size of 5056kB and misses the last few characters in the xml-file.... meanwhile the php code is not executed any further, but hangs on $zip->extractTo($mydir)... until the max execution time is reached.
 [2013-02-01 23:06 UTC] pajoye@php.net
Which version do you use? Peck install or bundled one?
 [2013-02-01 23:07 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2013-02-01 23:07 UTC] pajoye@php.net
Also drop me a mail with the archive or make it available somewhere please.
 [2013-02-02 11:23 UTC] pecl at xu9 dot de
In my first bug-report there is a link to an archive that triggers this error.

http://xu9.de/test.zip
 [2013-02-02 11:23 UTC] pecl at xu9 dot de
-Status: Feedback +Status: Open
 [2015-04-16 01:25 UTC] cmb@php.net
-Package: zip +Package: Zip Related -Assigned To: +Assigned To: cmb
 [2015-04-16 12:33 UTC] cmb@php.net
-Status: Assigned +Status: Feedback
 [2015-04-16 12:33 UTC] cmb@php.net
Unfortunately, the download link is broken now. Could you please
make the problematic zip archive available for download again?
 [2015-04-26 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 09:01:28 2024 UTC