[New-bugs-announce] [issue11152] pb in zipfile module

labem report at bugs.python.org
Tue Feb 8 16:22:16 CET 2011


New submission from labem <labem at E-i.com>:

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

----------
components: Library (Lib)
messages: 128180
nosy: Emmanuel LAB
priority: normal
severity: normal
status: open
title: pb in zipfile module
type: crash
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11152>
_______________________________________


More information about the New-bugs-announce mailing list