summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-09 16:34:03 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-03-09 16:34:03 (GMT)
commitfeccdb2a249a71be330765be77dee57121866779 (patch)
tree003b97627283dc69d2611d4abbbf10217a99fdb1 /Lib
parent964281af59d7a17d923c4d72357e48832b774e39 (diff)
downloadcpython-feccdb2a249a71be330765be77dee57121866779.zip
cpython-feccdb2a249a71be330765be77dee57121866779.tar.gz
cpython-feccdb2a249a71be330765be77dee57121866779.tar.bz2
bpo-29774: Improve error reporting for corrupted extra field in ZIP file. (#583)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/zipfile.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index b5c16db..8a19ca2 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -438,7 +438,9 @@ class ZipInfo (object):
unpack = struct.unpack
while len(extra) >= 4:
tp, ln = unpack('<HH', extra[:4])
- if tp == 1:
+ if ln+4 > len(extra):
+ raise BadZipFile("Corrupt extra field %04x (size=%d)" % (tp, ln))
+ if tp == 0x0001:
if ln >= 24:
counts = unpack('<QQQ', extra[4:28])
elif ln == 16: