Bug #53587 [Opn->Fbk]: "Seek error: Invalid argument" when creating ZIP larger than 2GB on 32bit arch
| From: | cmb@php.net | Date: | Mon, 18 May 2015 18:34:09 +0000 |
| Subject: | Bug #53587 [Opn->Fbk]: "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-192738@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
Updated by: cmb@php.net
Reported by: jerome dot auge at anakeen dot com
Summary: "Seek error: Invalid argument" when creating ZIP
larger than 2GB on 32bit arch
-Status: Open
+Status: Feedback
Type: Bug
Package: Zip Related
Operating System: Linux, Mac OS X
PHP Version: 5.3.4
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
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?
Previous Comments:
------------------------------------------------------------------------
[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