Bug #53587 [Com]: "Seek error: Invalid argument" when creating ZIP larger than 2GB on 32bit arch
| From: | jerome dot auge at anakeen dot com | Date: | Sun, 31 May 2015 09:35:24 +0000 |
| Subject: | Bug #53587 [Com]: "Seek error: Invalid argument" when creating ZIP larger than 2GB on 32bit arch | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193029@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=53587&edit=1
ID: 53587
Comment by: jerome dot auge at anakeen dot com
Reported by: jerome dot auge at anakeen dot com
Summary: "Seek error: Invalid argument" when creating ZIP
larger than 2GB on 32bit arch
Status: No Feedback
Type: Bug
Package: Zip Related
Operating System: Linux, Mac OS X
PHP Version: 5.3.4
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
I compiled php-5.6.9 on Debian 8 i686 with
./configure --enable-zip, and my test fails:
the output Zip file is not created and no error is reported (neither from Zip::addFile() nor
Zip::close()).
Previous Comments:
------------------------------------------------------------------------
[2015-05-31 04:22:17] 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.
------------------------------------------------------------------------
[2015-05-18 18:34:06] cmb@php.net
Zip64 support is supposed to be available since libzip 0.11. As of
PHP 5.6.8 libzip 0.11.2 or newer are bundled. For older PHP
versions PECL provides up-to-date zip extension packages (use
1.12.4 or newer): <https://pecl.php.net/package/zip>
Can you confirm that the issue is solved with latest PHP resp.
PECL zip versions?
------------------------------------------------------------------------
[2010-12-21 16:16:56] jerome dot auge at anakeen dot com
Package: "Zip Related"
------------------------------------------------------------------------
[2010-12-21 11:23:30] jerome dot auge at anakeen dot com
Description:
------------
On 32bit system, you can't generate ZIP files larger than 2GB.
I reproduce this with :
- PHP 5.3.4 on Mac OS 10.5 i686
Also observed with :
- PHP 5.2.4 on Ubuntu 8.04 i686
- PHP 5.3.2 on Ubuntu 10.04 i686
I tested with 3 files of 1GB random data. After adding the 3 files, the $zip-
>close() returns the error "Seek error: Invalid argument" and there is no zip
output file.
After looking into ext/zip, it seems that the problem is in the use of "unsigned
long" types instead of the "off_t" type in zip_cdir struct, and the fact that
the HAVE_FSEEKO and HAVE_FTELLO are not detected/defined by the ./configure
script.
On OS X (PHP 5.3.4), if I recompile the ext/zip extension by hand with the patch
below (force HAVE_FSEEKO/HAVE_FTELLO and adjust the "unsigned long" to "off_t"
in zip_cdir struct), then I can create my ZIP archive larger than 2GB.
Test script:
---------------
#!/bin/bash
# -- Create 3 files of 1GB random data
for I in 1 2 3; do dd if=/dev/urandom of=f$I bs=1M count=1024; done
# -- Create a 'out.zip' archive containing these 3 files
php -r '$zip = new ZipArchive(); $zip->open("out.zip", ZIPARCHIVE::CREATE);
$zip->addFile("f1"); $zip->addFile("f2");
$zip->addFile("f3"); $ret = $zip->close(); if( $ret === false ) { print
sprintf("Error: %s", $zip->getStatusString()); };'
zip -T out.zip
if [ $? -ne 0 ]; then
echo "ERROR"
exit 1
fi
echo "OK"
exit 0
Expected result:
----------------
A ZIP archive with a size around 3GB that passes the `zip -T' verification.
Actual result:
--------------
$zip->close() returns false with error "Seek error: Invalid argument", and the ZIP
output file is not produced.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=53587&edit=1