Bug #53587 [NEW]: "Seek error: Invalid argument" when creating ZIP larger than 2GB on 32bit arch

From: Date: Tue, 21 Dec 2010 10:23:38 +0000
Subject: Bug #53587 [NEW]: "Seek error: Invalid argument" when creating ZIP larger than 2GB on 32bit arch
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-157171@lists.php.net to get a copy of this message
From:             
Operating system: Linux, Mac OS X
PHP version:      5.3.4
Package:          *Compression related
Bug Type:         Bug
Bug description:"Seek error: Invalid argument" when creating ZIP larger than 2GB on 32bit
arch

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 bug report at http://bugs.php.net/bug.php?id=53587&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=53587&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=53587&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=53587&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=53587&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53587&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=53587&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=53587&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=53587&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=53587&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=53587&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=53587&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=53587&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=53587&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=53587&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53587&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53587&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=53587&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=53587&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=53587&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=53587&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=53587&r=mysqlcfg



Thread (8 messages)

« previous php.bugs (#157171) next »