|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52091 ZipArchive: CRC32 errors / corrupted archives not reported
Submitted: 2010-06-15 23:26 UTC Modified: 2017-10-24 07:38 UTC
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: hardcorevenom at gmx dot de Assigned:
Status: Open Package: Zip Related
PHP Version: 5.2.13 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: hardcorevenom at gmx dot de
New email:
PHP Version: OS:


 [2010-06-15 23:26 UTC] hardcorevenom at gmx dot de
I corrupted a file using a hex editor.
"echo shell_exec('unzip -t file')" shows the CRC32 mismatch.

ZipArchive::extractTo() doesn't report CRC32 errors.

Reading a stream received from ZipArchive::getStream('myfile') echoes a CRC error if the number of bytes read with one fread() is below 2157 bytes.

Test script:
$zip = new ZipArchive();
if ($zip->open('')) {
  zip->extractTo('mydir'); //no error printed

  $fp = $z->getStream('brokenfile');
  while (!feof($fp)) {
    $buf .= fread($fp, 2048+108); //CRC error printed

  $fp = $z->getStream('brokenfile');
  while (!feof($fp)) {
    $buf .= fread($fp, 2048+109); //CRC error NOT printed


Expected result:
A CRC32 error report that can be handled.

The one from "fread($fp, 2048+108)" is fine: "Warning: fread() [function.fread]: Zip stream error: CRC error in ..." (can be handled with "ob_get_contents()");

For "ZipArchive::extractTo()" the corrupt file(s) should be printed.

Actual result:
CRC32 errors are reported always.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-15 23:29 UTC] hardcorevenom at gmx dot de
-Summary: CRC32 Error not reported +Summary: ZipArchive: CRC32 errors / corrupted archives not reported
 [2010-06-15 23:29 UTC] hardcorevenom at gmx dot de
Summary modified.
 [2010-06-16 00:35 UTC] hardcorevenom at gmx dot de
"Actual result" should be
CRC32 errors are reported not always.
 [2010-06-20 17:49 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: pajoye
 [2010-06-20 17:57 UTC]
-Status: Assigned +Status: Feedback
 [2010-06-20 17:57 UTC]
Do you have an archive to reproduce this problem (small if possible :)?
 [2010-06-23 18:38 UTC] hardcorevenom at gmx dot de
-Status: Feedback +Status: Open
 [2010-06-23 18:38 UTC] hardcorevenom at gmx dot de
File "_test.php" is bad in this archive

Can be seen here:
 [2010-06-26 23:38 UTC]
-Status: Open +Status: Assigned
 [2011-01-31 16:27 UTC] schmale at froglogic dot com
Not the same bug, but related, as "ZipArchive::extractTo" seems to fail in giving a meaningful return value at all.

I used the method and specified an existing directory without write privileges, and got TRUE as return value (although "ZipArchive::extractTo" didn't do anything, due to lack of write privileges).
 [2011-01-31 16:54 UTC]
@schmale at froglogic dot com

If it is not the same then please open a new bug. Please provide both a script and 
an archive to reproduce your problem.
 [2016-09-06 15:30 UTC]
I can reproduce that ::extractTo() doesn't fail if the CRC32 of
the file is wrong. However, passing ZipArchive::CHECKCONS to
::open() lets this method fail with ZipArchive::ER_INCONS, so it
seems the behavior is desired.

IMO, that's a documentation issue.
 [2017-10-24 07:38 UTC]
-Status: Assigned +Status: Open -Assigned To: pajoye +Assigned To:
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 25 15:01:29 2024 UTC