diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-07-28 22:15:30 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2009-07-28 22:15:30 (GMT) |
commit | 3e5b027a64e9eccc8d2100e717c19f61d3a51d62 (patch) | |
tree | 22a56ccd993c67db9c46628be73fa8854bab0442 /Lib/zipfile.py | |
parent | e55df1fa2a9be432c5c22d7eec8b395227fa4405 (diff) | |
download | cpython-3e5b027a64e9eccc8d2100e717c19f61d3a51d62.zip cpython-3e5b027a64e9eccc8d2100e717c19f61d3a51d62.tar.gz cpython-3e5b027a64e9eccc8d2100e717c19f61d3a51d62.tar.bz2 |
#6511: ZipFile will now raise BadZipfile when opening an empty or tiny file,
like it does for larger invalid files.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r-- | Lib/zipfile.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index 6ee9923..2aa4bff 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -198,7 +198,10 @@ def _EndRecData(fpin): # Check to see if this is ZIP file with no archive comment (the # "end of central directory" structure should be the last item in the # file if this is the case). - fpin.seek(-sizeEndCentDir, 2) + try: + fpin.seek(-sizeEndCentDir, 2) + except IOError: + return None data = fpin.read() if data[0:4] == stringEndArchive and data[-2:] == "\000\000": # the signature is correct and there's no comment, unpack structure |