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.

classification
Title: pb in zipfile module
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Emmanuel LAB, alanmcintyre, dmcalloway, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2011-02-08 15:22 by Emmanuel LAB, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test11152.patch dmcalloway, 2013-07-29 01:33 Test for Issue 11152 review
Messages (3)
msg128180 - (view) Author: labem (Emmanuel LAB) Date: 2011-02-08 15:22
Detected in Python version:
Python 2.6.3 (r263rc1:75186, Oct  2 2009, 20:40:30) [MSC v.1500 32 bit (Intel)] on win32

Error in zipfile module: Zip files with no compressed files may contain only 
   [end of central directory record] bloc
without anything else. In that case, when _EndRecData(fpin) function tries to call:
         return _EndRecData64(fpin, -sizeEndCentDir, endrec)
it makes _EndRecData64() trying to seek data in the file before the beginning of the file and generates IOError "Invalid Argument" which is :
* either badly (in is_zipfile()), 
* or not catched (in __init()__._GetContents()._RealGetContents().EndRecData()).

Correction seems easy (not tested) and just need to replace:
        # Try to read the "Zip64 end of central directory" structure
        return _EndRecData64(fpin, -sizeEndCentDir, endrec)
by:
        # check if other block are present
        if filesize > sizeEndCentDir:
            # Try to read the "Zip64 end of central directory" structure
            return _EndRecData64(fpin, -sizeEndCentDir, endrec)
        else:
        		# no other block present
            return endrec
msg193845 - (view) Author: Damien M Calloway (dmcalloway) * Date: 2013-07-29 01:33
I believe I have isolated the bug - I added a blank string to the SMALL TEST DATA list, since empty strings will not compress. Test now fails on lines 645 and 663 when "extract" and "extract_all" assertions fail. This appears to replicate the issue reported.
msg235450 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-02-05 19:50
Looks as this bug was fixed in issue1710703.
History
Date User Action Args
2022-04-11 14:57:12adminsetgithub: 55361
2015-02-05 19:50:49serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg235450

resolution: out of date
stage: test needed -> resolved
2013-07-29 01:33:42dmcallowaysetfiles: + test11152.patch
keywords: + patch
messages: + msg193845
2013-07-26 23:10:00dmcallowaysetnosy: + dmcalloway
2011-02-08 22:56:12eric.araujosetnosy: alanmcintyre, Emmanuel LAB
stage: test needed
type: crash -> behavior
versions: + Python 3.1, Python 2.7, Python 3.2, Python 3.3, - Python 2.6
2011-02-08 22:55:36eric.araujosetnosy: + alanmcintyre
2011-02-08 15:22:15Emmanuel LABcreate