[issue9720] zipfile writes incorrect local file header for large files in zip64

2013-01-14 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ce869b05762c by Serhiy Storchaka in branch '2.7':
Issue #9720: zipfile now writes correct local headers for files larger than 4 
GiB.
http://hg.python.org/cpython/rev/ce869b05762c

New changeset b93848ca7760 by Serhiy Storchaka in branch '3.2':
Issue #9720: zipfile now writes correct local headers for files larger than 4 
GiB.
http://hg.python.org/cpython/rev/b93848ca7760

New changeset 656a45738e5e by Serhiy Storchaka in branch '3.3':
Issue #9720: zipfile now writes correct local headers for files larger than 4 
GiB.
http://hg.python.org/cpython/rev/656a45738e5e

New changeset 628a6af64a46 by Serhiy Storchaka in branch 'default':
Issue #9720: zipfile now writes correct local headers for files larger than 4 
GiB.
http://hg.python.org/cpython/rev/628a6af64a46

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2013-01-14 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Fixed. Thank you for report, Craig de Stigter.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2013-01-04 Thread Nico Möller

Nico Möller added the comment:

I most definitely need a patch for 2.7.3 

Would be awesome if you could provide a patch for that version.

--
nosy: +Nico.Möller

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2013-01-04 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here are second variant patches for 2.7 and 3.2.

--
Added file: http://bugs.python.org/file28558/zipfile_zip64_try_2-2.7.patch
Added file: http://bugs.python.org/file28559/zipfile_zip64_try_2-3.2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___diff -r c8e885ecbc89 Lib/zipfile.py
--- a/Lib/zipfile.pyThu Jan 03 20:34:19 2013 -0800
+++ b/Lib/zipfile.pyFri Jan 04 15:24:35 2013 +0200
@@ -316,7 +316,7 @@
 # compress_size Size of the compressed file
 # file_size Size of the uncompressed file
 
-def FileHeader(self):
+def FileHeader(self, zip64=None):
 Return the per-file header as a string.
 dt = self.date_time
 dosdate = (dt[0] - 1980)  9 | dt[1]  5 | dt[2]
@@ -331,12 +331,17 @@
 
 extra = self.extra
 
-if file_size  ZIP64_LIMIT or compress_size  ZIP64_LIMIT:
-# File is larger than what fits into a 4 byte integer,
-# fall back to the ZIP64 extension
+if zip64 is None:
+zip64 = file_size  ZIP64_LIMIT or compress_size  ZIP64_LIMIT
+if zip64:
 fmt = 'HHQQ'
 extra = extra + struct.pack(fmt,
 1, struct.calcsize(fmt)-4, file_size, compress_size)
+if file_size  ZIP64_LIMIT or compress_size  ZIP64_LIMIT:
+if not zip64:
+raise LargeZipFile(Filesize would require ZIP64 extensions)
+# File is larger than what fits into a 4 byte integer,
+# fall back to the ZIP64 extension
 file_size = 0x
 compress_size = 0x
 self.extract_version = max(45, self.extract_version)
@@ -1113,20 +1118,23 @@
 zinfo.CRC = 0
 self.filelist.append(zinfo)
 self.NameToInfo[zinfo.filename] = zinfo
-self.fp.write(zinfo.FileHeader())
+self.fp.write(zinfo.FileHeader(False))
 return
 
 with open(filename, rb) as fp:
 # Must overwrite CRC and sizes with correct data later
 zinfo.CRC = CRC = 0
 zinfo.compress_size = compress_size = 0
-zinfo.file_size = file_size = 0
-self.fp.write(zinfo.FileHeader())
+# Compressed size can be larger than uncompressed size
+zip64 = self._allowZip64 and \
+zinfo.file_size * 1.05  ZIP64_LIMIT
+self.fp.write(zinfo.FileHeader(zip64))
 if zinfo.compress_type == ZIP_DEFLATED:
 cmpr = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION,
  zlib.DEFLATED, -15)
 else:
 cmpr = None
+file_size = 0
 while 1:
 buf = fp.read(1024 * 8)
 if not buf:
@@ -1146,11 +1154,16 @@
 zinfo.compress_size = file_size
 zinfo.CRC = CRC
 zinfo.file_size = file_size
-# Seek backwards and write CRC and file sizes
+if not zip64 and self._allowZip64:
+if file_size  ZIP64_LIMIT:
+raise RuntimeError('File size has increased during 
compressing')
+if compress_size  ZIP64_LIMIT:
+raise RuntimeError('Compressed size larger than uncompressed 
size')
+# Seek backwards and write file header (which will now include
+# correct CRC and file sizes)
 position = self.fp.tell()   # Preserve current position in file
-self.fp.seek(zinfo.header_offset + 14, 0)
-self.fp.write(struct.pack(LLL, zinfo.CRC, zinfo.compress_size,
-  zinfo.file_size))
+self.fp.seek(zinfo.header_offset, 0)
+self.fp.write(zinfo.FileHeader(zip64))
 self.fp.seek(position, 0)
 self.filelist.append(zinfo)
 self.NameToInfo[zinfo.filename] = zinfo
@@ -1187,14 +1200,18 @@
 zinfo.compress_size = len(bytes)# Compressed size
 else:
 zinfo.compress_size = zinfo.file_size
-zinfo.header_offset = self.fp.tell()# Start of header bytes
-self.fp.write(zinfo.FileHeader())
+zip64 = zinfo.file_size  ZIP64_LIMIT or \
+zinfo.compress_size  ZIP64_LIMIT
+if zip64 and not self._allowZip64:
+raise LargeZipFile(Filesize would require ZIP64 extensions)
+self.fp.write(zinfo.FileHeader(zip64))
 self.fp.write(bytes)
-self.fp.flush()
 if zinfo.flag_bits  0x08:
 # Write CRC and file sizes after the file data
-self.fp.write(struct.pack(LLL, zinfo.CRC, zinfo.compress_size,
+fmt = 'LQQ' if zip64 else 'LLL'
+self.fp.write(struct.pack(fmt, zinfo.CRC, zinfo.compress_size,
   zinfo.file_size))
+self.fp.flush()
 self.filelist.append(zinfo)
 self.NameToInfo[zinfo.filename] = 

[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-12-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What variant of patches should I commit? Or prepare other?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-12-29 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
assignee:  - serhiy.storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-11-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Patches updated to resolve merge conflict with issue11981.

Please review and apply any of this patches. This is needed for some
other my zipfile patches.

--
Added file: http://bugs.python.org/file28145/zipfile_zip64_always_2.patch
Added file: http://bugs.python.org/file28146/zipfile_zip64_try_2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___diff -r 6f3d3003acf3 Lib/zipfile.py
--- a/Lib/zipfile.pyWed Nov 28 12:34:27 2012 +0200
+++ b/Lib/zipfile.pyWed Nov 28 14:15:29 2012 +0200
@@ -346,7 +346,7 @@
 # compress_size Size of the compressed file
 # file_size Size of the uncompressed file
 
-def FileHeader(self):
+def FileHeader(self, zip64=None):
 Return the per-file header as a string.
 dt = self.date_time
 dosdate = (dt[0] - 1980)  9 | dt[1]  5 | dt[2]
@@ -362,12 +362,17 @@
 extra = self.extra
 
 min_version = 0
-if file_size  ZIP64_LIMIT or compress_size  ZIP64_LIMIT:
-# File is larger than what fits into a 4 byte integer,
-# fall back to the ZIP64 extension
+if zip64 is None:
+zip64 = file_size  ZIP64_LIMIT or compress_size  ZIP64_LIMIT
+if zip64:
 fmt = 'HHQQ'
 extra = extra + struct.pack(fmt,
 1, struct.calcsize(fmt)-4, file_size, compress_size)
+if file_size  ZIP64_LIMIT or compress_size  ZIP64_LIMIT:
+if not zip64:
+raise LargeZipFile(Filesize would require ZIP64 extensions)
+# File is larger than what fits into a 4 byte integer,
+# fall back to the ZIP64 extension
 file_size = 0x
 compress_size = 0x
 min_version = ZIP64_VERSION
@@ -1301,7 +1306,7 @@
 zinfo.CRC = 0
 self.filelist.append(zinfo)
 self.NameToInfo[zinfo.filename] = zinfo
-self.fp.write(zinfo.FileHeader())
+self.fp.write(zinfo.FileHeader(False))
 return
 
 cmpr = _get_compressor(zinfo.compress_type)
@@ -1309,8 +1314,9 @@
 # Must overwrite CRC and sizes with correct data later
 zinfo.CRC = CRC = 0
 zinfo.compress_size = compress_size = 0
-zinfo.file_size = file_size = 0
-self.fp.write(zinfo.FileHeader())
+# Compressed size can be larger than uncompressed size
+self.fp.write(zinfo.FileHeader(self._allowZip64))
+file_size = 0
 while 1:
 buf = fp.read(1024 * 8)
 if not buf:
@@ -1330,11 +1336,11 @@
 zinfo.compress_size = file_size
 zinfo.CRC = CRC
 zinfo.file_size = file_size
-# Seek backwards and write CRC and file sizes
+# Seek backwards and write file header (which will now include
+# correct CRC and file sizes)
 position = self.fp.tell()   # Preserve current position in file
-self.fp.seek(zinfo.header_offset + 14, 0)
-self.fp.write(struct.pack(LLL, zinfo.CRC, zinfo.compress_size,
-  zinfo.file_size))
+self.fp.seek(zinfo.header_offset, 0)
+self.fp.write(zinfo.FileHeader(self._allowZip64))
 self.fp.seek(position, 0)
 self.filelist.append(zinfo)
 self.NameToInfo[zinfo.filename] = zinfo
@@ -1376,13 +1382,18 @@
 zinfo.compress_size = len(data)# Compressed size
 else:
 zinfo.compress_size = zinfo.file_size
-self.fp.write(zinfo.FileHeader())
+zip64 = zinfo.file_size  ZIP64_LIMIT or \
+zinfo.compress_size  ZIP64_LIMIT
+if zip64 and not self._allowZip64:
+raise LargeZipFile(Filesize would require ZIP64 extensions)
+self.fp.write(zinfo.FileHeader(zip64))
 self.fp.write(data)
-self.fp.flush()
 if zinfo.flag_bits  0x08:
 # Write CRC and file sizes after the file data
-self.fp.write(struct.pack(LLL, zinfo.CRC, zinfo.compress_size,
+fmt = 'LQQ' if zip64 else 'LLL'
+self.fp.write(struct.pack(fmt, zinfo.CRC, zinfo.compress_size,
   zinfo.file_size))
+self.fp.flush()
 self.filelist.append(zinfo)
 self.NameToInfo[zinfo.filename] = zinfo
 
diff -r 6f3d3003acf3 Lib/zipfile.py
--- a/Lib/zipfile.pyWed Nov 28 12:34:27 2012 +0200
+++ b/Lib/zipfile.pyWed Nov 28 14:15:50 2012 +0200
@@ -346,7 +346,7 @@
 # compress_size Size of the compressed file
 # file_size Size of the uncompressed file
 
-def FileHeader(self):
+def FileHeader(self, zip64=None):
 Return the per-file header as a string.
 dt = self.date_time
 dosdate = (dt[0] - 1980)  9 | dt[1]  5 | dt[2]
@@ -362,12 +362,17 @@
 

[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-11-26 Thread Jon Henry

Changes by Jon Henry jhe...@ccs.neu.edu:


--
nosy: +jhenry82

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-11-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Please, review the patches.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-10-19 Thread Ruben Gonzalez

Changes by Ruben Gonzalez ruben...@teltek.es:


--
nosy: +Ruben.Gonzalez

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-10-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What the conclusion about the patches? Which variant I should backport for 
older versions?

--
versions: +Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-10-11 Thread Ronald Oussoren

Ronald Oussoren added the comment:

I'd write the extended header when the current file size is larger than the 
zip64 limit (that is, when 'st.st_size  ZIP64_LIMIT' in the write method.

That way the minimal header size is used whenever possible.

As you noted this can cause problems when the file grows beyond the limit while 
it is stored in the zipfile, but IMHO storing data while it is modified is 
asking for problems anyway.

BTW. I haven't actually review the patch yet.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-09-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I see two rational solutions of the issue (all written below is applicable only 
for allowZip64=True):

1) Always write Zip64 extended information extra field. This approach always 
successful, but the zipfile size will increase by 20 bytes for each file.

The first patch (zipfile_zip64_always.patch) uses this approach.

2) Write Zip64 extended information extra field only if assumed file size is 
more than a certain limit. In very rare cases this leads to the impossibility 
of compression of the file which can be compressed the first way. However it 
produces the same file as before patch in most cases.

The second patch (zipfile_zip64_try.patch) is based on Alan's patch and uses 
the second approach. The probability of errors is reduced and they are now 
detected and does not lead to a silent data damage.

Both patches are for Python 3.3. If any patch is good, I'll backport it for the 
older versions.

--
nosy: +gregory.p.smith, loewis, ronaldoussoren
Added file: http://bugs.python.org/file27262/zipfile_zip64_always.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-09-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
stage: needs patch - patch review
Added file: http://bugs.python.org/file27263/zipfile_zip64_try.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-09-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

No, on the contrary, it is not such easy to fix, and the patch is incorrect. 
Sorry that it is not clear either. The size of the header with extra args 
depends on the size of the file. The file size can be changed in the process of 
compressing, and compressed size may be larger than uncompressed size, 
exceeding 32-bit boundary. Rewriting the header with extra args, we can 
overwrite compressed data.

I was put off the issue for further more careful research. Thanks for the 
reminder.

One solution is always (even for smallest files) to write 64-bit sizes when 
allowZip64 is true.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-09-18 Thread Kristof Keppens

Changes by Kristof Keppens kkepp...@gmail.com:


--
nosy: +Kristof.Keppens

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-09-18 Thread Christian Heimes

Christian Heimes added the comment:

Serhiy:
If I understand you correctly it should be easy to fix. The code in close() has 
to check if any file is beyond the ZIP64 limit and then write all headers with 
extra args. Is that correct?

--
keywords: +needs review
nosy: +christian.heimes

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-03-20 Thread David Andrzejewski

Changes by David Andrzejewski site+python@davidandrzejewski.com:


--
nosy: +dandrzejewski

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-03-20 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2012-03-20 Thread Serhiy Storchaka

Serhiy Storchaka storch...@gmail.com added the comment:

I am afraid that the problem is more complicated. With the option 
allowZip64=True all files need to write with this extension, because size of 
local file header may change and there will be after compression just go back 
and rewrite it.

Now it appears that the Zip64 option simply does not work.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2011-11-03 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

Issue 6434 was marked as a duplicate of this issue.

--
nosy: +Paul, amaury.forgeotdarc, enlavin, lambacck, nadeem.vawda, segfault42
stage:  - needs patch
versions: +Python 3.3 -Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: [issue9720] zipfile writes incorrect local file header for large files in zip64

2011-06-26 Thread goodwin.gt



 Alan McIntyre alan.mcint...@gmail.com added the comment:
 
 Here's an updated patch for the py3k trunk with tests.  This pretty much
 doubles the runtime of test_zipfile64.py.  The patch also removes some
 unnecessary code from the existing test_zipfile64 tests.
 

Hello Alan

I've faced this problem too.
I start packing a 4.73GB file, and receive the struct error as follows:

1) Python 2.7.2 production:

...
  File C:\Python27\lib\zipfile.py, line 1100, in write
zinfo.file_size))
struct.error: integer out of range for 'L' format code

2) Python 3.2 production:

...
  File C:\Python32\lib\zipfile.py, line 1142, in write
zinfo.file_size))
struct.error: argument out of range



Environment: Windows 7 Ultimate 32bit

Everytime packing process fails at 4,981,808,577 byte

I need a patch for Python 2.7.2 .
Could you adapt your patch appropriately?

Thanks.

-- 
View this message in context: 
http://old.nabble.com/-issue9720--zipfile-writes-incorrect-local-file-header-for-large-files-in-zip64-tp29578646p31928738.html
Sent from the Python - python-bugs-list mailing list archive at Nabble.com.

___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2010-09-06 Thread Alan McIntyre

Alan McIntyre alan.mcint...@gmail.com added the comment:

Here's an updated patch for the py3k trunk with tests.  This pretty much 
doubles the runtime of test_zipfile64.py.  The patch also removes some 
unnecessary code from the existing test_zipfile64 tests.

Note: It looks like writestr will also suffer from a struct.pack overflow if 
it's given a ZipInfo with the third general purpose flag bit set.  I won't have 
time to address that until next weekend, probably.

--
Added file: http://bugs.python.org/file18780/zipfile-huge-files.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2010-09-05 Thread Alan McIntyre

Alan McIntyre alan.mcint...@gmail.com added the comment:

Thanks for the patch, Craig; I should have some time later today or tomorrow to 
do a review.  Did you have a patch for the test suite(s) as well?  If not, I 
can just make sure your test case is covered in test_zipfile64.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2010-09-05 Thread Craig de Stigter

Craig de Stigter craig...@gmail.com added the comment:

Hi, sorry no I haven't had time to add a real test for this

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2010-09-03 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

A tip about versions: Development happens on the current active branch, py3k 
(future 3.2 version), and bug or doc fixes are backported to the stable 
versions 2.7 and 3.1. Security fixes go into 2.6 too.

Can you reproduce your bug in 2.7, 3.1 and 3.2?

Adding Alan to nosy since he’s listed in Misc/maintainers.rst.

--
nosy: +alanmcintyre, eric.araujo
versions:  -Python 2.5, Python 2.6, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2010-09-03 Thread Craig de Stigter

Craig de Stigter craig...@gmail.com added the comment:

Yes, the bug still exists in Python 3.1.2. However, struct.pack() no longer 
silently ignores overflow, so I get this error instead:


 z.write('foo.txt')
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python3.1/zipfile.py, line 1095, in write
zinfo.file_size))
struct.error: argument out of range

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9720] zipfile writes incorrect local file header for large files in zip64

2010-08-30 Thread Craig de Stigter

New submission from Craig de Stigter craig...@gmail.com:

Steps to reproduce:

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

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


Now inspect the file headers using a hex editor. The written headers are 
incorrect. The filesize and compressed size should be written as 0x 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.)

--
components: Library (Lib)
files: zipfile_zip64_header.patch
keywords: patch
messages: 115250
nosy: craigds
priority: normal
severity: normal
status: open
title: zipfile writes incorrect local file header for large files in zip64
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file18685/zipfile_zip64_header.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9720
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com