Fix issue #14315: The zipfile module now ignores extra fields in the central

directory that are too short to be parsed instead of letting a struct.unpack
error bubble up as this "bad data" appears in many real world zip files in the
wild and is ignored by other zip tools.
This commit is contained in:
Gregory P. Smith 2014-05-29 23:42:14 -07:00
parent 58cfdd8af8
commit 0af8a86be8
3 changed files with 21 additions and 1 deletions

View file

@ -411,7 +411,7 @@ class ZipInfo (object):
# Try to decode the extra field.
extra = self.extra
unpack = struct.unpack
while extra:
while len(extra) >= 4:
tp, ln = unpack('<HH', extra[:4])
if tp == 1:
if ln >= 24: