Edit report at http://bugs.php.net/bug.php?id=53587&edit=1

 ID:                 53587
 User updated 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:             Open
 Type:               Bug
-Package:            *Compression related
+Package:            Zip Related
 Operating System:   Linux, Mac OS X
 PHP Version:        5.3.4
 Block user comment: N
 Private report:     N

 New Comment:

Package: "Zip Related"


Previous Comments:
------------------------------------------------------------------------
[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 http://bugs.php.net/bug.php?id=53587&edit=1

Reply via email to