bpo-29774: Improve error reporting for corrupted extra field in ZIP file. (#583)

This commit is contained in:
Serhiy Storchaka 2017-03-09 18:34:03 +02:00 committed by Victor Stinner
parent 964281af59
commit feccdb2a24
1 changed files with 3 additions and 1 deletions

View File

@ -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: