[ python-Bugs-1742205 ] ZipFile.writestr writes incorrect extended local headers

SourceForge.net noreply at sourceforge.net
Sat Jun 23 21:07:40 CEST 2007


Bugs item #1742205, was opened at 2007-06-23 16:07
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742205&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: alexis (asak)
Assigned to: Nobody/Anonymous (nobody)
Summary: ZipFile.writestr writes incorrect extended local headers

Initial Comment:
According to http://www.onicos.com/staff/iz/formats/zip.html the format of an optional extended local header is:

Extended local header:
Offset   Length   Contents
  0      4 bytes  Extended Local file header signature (0x08074b50)
  4      4 bytes  CRC-32
  8      4 bytes  Compressed size
 12      4 bytes  Uncompressed size

If you call ZipFile.writestr passing a ZipInfo where flag_bits & 0x08 is true, it will try to write an extended local header, but it won't write the header signature.

Even though (on Linux) unzip doesn't complain about it, a zip -T file.zip tells me:

$ zip -T file.zip
	zip warning: extended local header not found for filename

zip error: Zip file structure invalid (file.zip)


Tested on a debian unstable system, with Python 2.3.5, 2.4.4 and 2.5.1.

I'm attaching a simple test case.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742205&group_id=5470


More information about the Python-bugs-list mailing list