Skip to content

Commit feccdb2

Browse files
serhiy-storchakavstinner
authored andcommitted
bpo-29774: Improve error reporting for corrupted extra field in ZIP file. (python#583)
1 parent 964281a commit feccdb2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/zipfile.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,9 @@ def _decodeExtra(self):
438438
unpack = struct.unpack
439439
while len(extra) >= 4:
440440
tp, ln = unpack('<HH', extra[:4])
441-
if tp == 1:
441+
if ln+4 > len(extra):
442+
raise BadZipFile("Corrupt extra field %04x (size=%d)" % (tp, ln))
443+
if tp == 0x0001:
442444
if ln >= 24:
443445
counts = unpack('<QQQ', extra[4:28])
444446
elif ln == 16:

0 commit comments

Comments
 (0)