commit | feccdb2a249a71be330765be77dee57121866779 | [log] [tgz] |
---|---|---|
author | Serhiy Storchaka <storchaka@gmail.com> | Thu Mar 09 18:34:03 2017 +0200 |
committer | Victor Stinner <victor.stinner@gmail.com> | Thu Mar 09 17:34:03 2017 +0100 |
tree | 003b97627283dc69d2611d4abbbf10217a99fdb1 | |
parent | 964281af59d7a17d923c4d72357e48832b774e39 [diff] [blame] |
bpo-29774: Improve error reporting for corrupted extra field in ZIP file. (#583)
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 @@ 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: