summaryrefslogtreecommitdiffstats
path: root/Lib/zipfile.py
diff options
context:
space:
mode:
authorDaniel Hillier <daniel.hillier@gmail.com>2019-10-29 07:24:18 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2019-10-29 07:24:18 (GMT)
commitda6ce58dd5ac109485af45878fca6bfd265b43e9 (patch)
tree05b7f6dc9bcdc8cd6b9a781da8a1caeb9b344399 /Lib/zipfile.py
parent4c155f738dc2e70ccb574f5169ad89c01753c6f7 (diff)
downloadcpython-da6ce58dd5ac109485af45878fca6bfd265b43e9.zip
cpython-da6ce58dd5ac109485af45878fca6bfd265b43e9.tar.gz
cpython-da6ce58dd5ac109485af45878fca6bfd265b43e9.tar.bz2
bpo-36993: Improve error reporting for zipfiles with bad zip64 extra data. (GH-14656)
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r--Lib/zipfile.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 6201edc..6504e0e 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -480,14 +480,26 @@ class ZipInfo (object):
# ZIP64 extension (large files and/or large archives)
if self.file_size in (0xffffffffffffffff, 0xffffffff):
+ if len(counts) <= idx:
+ raise BadZipFile(
+ "Corrupt zip64 extra field. File size not found."
+ )
self.file_size = counts[idx]
idx += 1
if self.compress_size == 0xFFFFFFFF:
+ if len(counts) <= idx:
+ raise BadZipFile(
+ "Corrupt zip64 extra field. Compress size not found."
+ )
self.compress_size = counts[idx]
idx += 1
if self.header_offset == 0xffffffff:
+ if len(counts) <= idx:
+ raise BadZipFile(
+ "Corrupt zip64 extra field. Header offset not found."
+ )
old = self.header_offset
self.header_offset = counts[idx]
idx+=1