Author craigds
Recipients craigds
Date 2010-08-31.01:02:13
SpamBayes Score 2.8722e-12
Marked as misclassified No
Message-id <>
Steps to reproduce:

# create a large (>4gb) file
f = open('foo.txt', 'wb')
text = 'a' * 1024**2
for i in xrange(5 * 1024):

# now zip the file
import zipfile
z = zipfile.ZipFile('', mode='w', allowZip64=True)

Now inspect the file headers using a hex editor. The written headers are incorrect. The filesize and compressed size should be written as 0xffffffff and the 'extra field' should contain the actual sizes.

Tested on Python 2.5 but looking at the latest code in 3.2 it still looks broken.

The problem is that the ZipInfo.FileHeader() is written before the filesize is populated, so Zip64 extensions are not written. Later, the sizes in the header are written, but Zip64 extensions are not taken into account and the filesize is just wrapped (7gb becomes 3gb, for instance).

My patch fixes the problem on Python 2.5, it might need minor porting to fix trunk. It works by assigning the uncompressed filesize to the ZipInfo header initially, then writing the header. Then later on, I re-write the header (this is okay since the header size will not have increased.)
Date User Action Args
2010-08-31 01:02:20craigdssetrecipients: + craigds
2010-08-31 01:02:20craigdssetmessageid: <>
2010-08-31 01:02:16craigdslinkissue9720 messages
2010-08-31 01:02:15craigdscreate