libzip: libzip-discuss: Possible bug with file >2gb

Thread

Thread Index

Message

From: Andrew Brampton <brampton%gmail.com@localhost>
To: libzip-discuss%nih.at@localhost
Subject: Possible bug with file >2gb
Date: Sun, 30 May 2010 13:17:36 +0100

Hi,
I've tried to debug this the best I can, but I've now got stuck
because I'm unfamiliar with the code.

I have a set of zip files (created by someone else). Most of them are
>1GB, and a couple of them are >2GB. I've been using PHP to open the
zip files and everything has been great until I had to deal with the
2GB files. PHP would return the ZIP_ER_NOZIP error code. By
recompiling PHP (with printfs inside libzip) I was able to work out
_zip_dirent_read returned -1 because the magic did not match. Now
working backwards through the file I found I can fix this by changing
_zip_readcdir. Around line 230 is this:

if (cd->size < (unsigned int)(eocd-buf)) {
 ... // Use existing buffer
} else {
 ... // Seek and read from file.
}

In this context cd->size is 3880 and is less than (eocd-buf), thus
uses the buffer that has already been read in. But later the magic
does not match inside _zip_dirent_read. However, if I comment out the
first part of the if and always use the 2nd branch (ie Seek and read
from file), then the magic matches and libzip gets a lot further into
dealing with my file, but eventually fails later after reading each
central directory file header, but I didn't investigate this further.

As far as I know this zip file is valid, and the linux unzip command
can handle it ok (which I assume doesn't use libzip?).

I am using PHP 5.3.2, but I'm unsure which version of libzip it is
using. The libzip files do have 1999-2009 in their copyright banners.
I'm on a Debain Linux machine with a 64bit processor.

What should I do to further debug this problem? and what more
information can I provide? I can't make the actual zip files
available. I have uploaded the output of "zipinfo -v" (with the file
names slightly altered as they are sensitive) here
http://bramp.net/test.info.

thanks in advance
Andrew

Made by MHonArc.