This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ymgve
Recipients ymgve
Date 2009-01-05.15:24:09
SpamBayes Score 0.0005758506
Marked as misclassified No
Message-id <1231169051.46.0.731825269948.issue4844@psf.upfronthosting.co.za>
In-reply-to
Content
If you have a .zip file with an incomplete "End of Central Directory" 
record, _EndRecData() will throw a struct.error:

D:\c64workdir\Ultimate_Mag_Archive>e:ziptest.py "old - 
Ultimate_Mag_Archive"
Handling A-z\0\64times01-double.zip
Traceback (most recent call last):
  File "E:\wwwroot\c64db\tools\ziptest.py", line 48, in <module>
    ok = handle_file(data, rel_filename)
  File "E:\wwwroot\c64db\tools\ziptest.py", line 19, in handle_file
    z = zipfile.ZipFile(cStringIO.StringIO(data), "r")
  File "C:\Python26\lib\zipfile.py", line 698, in __init__
    self._GetContents()
  File "C:\Python26\lib\zipfile.py", line 718, in _GetContents
    self._RealGetContents()
  File "C:\Python26\lib\zipfile.py", line 728, in _RealGetContents
    endrec = _EndRecData(fp)
  File "C:\Python26\lib\zipfile.py", line 219, in _EndRecData
    endrec = list(struct.unpack(structEndArchive, recData))
struct.error: unpack requires a string argument of length 22

The fix is to include a check to see if there is data enough for the 
whole record before attempting to unpack.
History
Date User Action Args
2009-01-05 15:24:11ymgvesetrecipients: + ymgve
2009-01-05 15:24:11ymgvesetmessageid: <1231169051.46.0.731825269948.issue4844@psf.upfronthosting.co.za>
2009-01-05 15:24:10ymgvelinkissue4844 messages
2009-01-05 15:24:09ymgvecreate