bpo-29774: Improve error reporting for corrupted extra field in ZIP f… · python/cpython@feccdb2 (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Commit feccdb2

serhiy-storchakavstinner

authored and

committed

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

File tree

1 file changed

lines changed

1 file changed

lines changed

Lines changed: 3 additions & 1 deletion

Original file line number Diff line number Diff line change
@@ -438,7 +438,9 @@ def _decodeExtra(self):
438 438 unpack = struct.unpack
439 439 while len(extra) >= 4:
440 440 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:
442 444 if ln >= 24:
443 445 counts = unpack('<QQQ', extra[4:28])
444 446 elif ln == 16: