php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44974 ZipArchive can't open large archives
Submitted: 2008-05-12 18:19 UTC Modified: 2009-03-04 10:32 UTC
Votes:9
Avg. Score:5.0 ± 0.0
Reproduced:9 of 9 (100.0%)
Same Version:9 (100.0%)
Same OS:4 (44.4%)
From: florian dot ember at gmail dot com Assigned: pajoye (profile)
Status: Closed Package: Zip Related
PHP Version: 5.2.6 OS: Debian
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: florian dot ember at gmail dot com
New email:
PHP Version: OS:

 

 [2008-05-12 18:19 UTC] florian dot ember at gmail dot com
Description:
------------
Opening archives with more than 1300 or so files fails with ER_READ. I encountered this while using the close/reopen method to avoid using up all available filehandles. On a Windows box the script below runs without errors.

Reproduce code:
---------------
<?php
$za = new ZipArchive;
$za->open('./useless.zip', ZipArchive::CREATE);
for ($i = 1; $i <= 2000; ++$i) {
	$file = "$i.txt";
	touch($file);
	if (!$za->addFile("./$file", $file)) {
		exit("Couldn't add $file");
	}
	echo "Added $file<br />\n";
	if ($za->numFiles % 100 == 0) {
		$za->close();
		$res = $za->open('./useless.zip', ZipArchive::CREATE);
		if ($res !== true) {
			exit("Close/reopen: Error #$res @ $i");
		}
		echo "Close/reopen @ $i<br />\n";
	}
}
unlink('./useless.zip');
echo 'Done.';

Expected result:
----------------
Added 1.txt
Added 2.txt
[...]
Added 2000.txt
Done.

Actual result:
--------------
Added 1.txt
Added 2.txt
[...]
Added 1299.txt
Close/reopen: Error #5 @ 1300

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-29 11:07 UTC] vadim at vadiaz dot com
This looks like exactly the same bug as http://bugs.php.net/bug.php?id=44055 - zip archive with more than 1000 entries in root or archive produce an error on 64bit Linux systems
I fixed it and rebuild php from source for my servers
the patch is:

--- php-5.2.6.orig/ext/zip/lib/zip_open.c	2008-01-14 05:19:41.000000000 +0200
+++ php-5.2.6/ext/zip/lib/zip_open.c	2008-07-29 14:04:36.000000000 +0300
@@ -313,7 +313,7 @@
 	/* go to start of cdir and read it entry by entry */
 	bufp = NULL;
 	clearerr(fp);
-	fseek(fp, -(cd->size+cd->comment_len+EOCDLEN), SEEK_END);
+	fseek(fp, -((long)(cd->size+cd->comment_len+EOCDLEN)), SEEK_END);
 	if (ferror(fp) || ((unsigned int)ftell(fp) != cd->offset)) {
 	    /* seek error or offset of cdir wrong */
 	    if (ferror(fp))
 [2008-08-08 00:31 UTC] florian dot ember at gmail dot com
Sorry, I can't do that. I ran the reproduce code on a shared host and I don't have a Debian / Linux installation at hand.
 [2008-08-18 07:35 UTC] pajoye@php.net
You can try using our pre-built binaries or windows or on any other linux distributions using our src packages. PHP does not have to be installed to test a fresh build.
 [2008-08-26 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-03-04 10:32 UTC] pajoye@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 14:01:30 2024 UTC