diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2012-05-01 12:08:22 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2012-05-01 12:08:22 (GMT) |
commit | d099b56be77c782b969ccf5912ab01a3b313c759 (patch) | |
tree | 4ed4ca1fc9dd9a3c30d731c02243f91e1c420778 /Lib/zipfile.py | |
parent | 67c14444545a7a9882665679672f0ddeac9cf635 (diff) | |
download | cpython-d099b56be77c782b969ccf5912ab01a3b313c759.zip cpython-d099b56be77c782b969ccf5912ab01a3b313c759.tar.gz cpython-d099b56be77c782b969ccf5912ab01a3b313c759.tar.bz2 |
Check extract_version when opening a zipfile.
Diffstat (limited to 'Lib/zipfile.py')
-rw-r--r-- | Lib/zipfile.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/zipfile.py b/Lib/zipfile.py index f5564da..c53b127 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -57,6 +57,8 @@ ZIP_BZIP2 = 12 DEFAULT_VERSION = 20 ZIP64_VERSION = 45 BZIP2_VERSION = 46 +# we recognize (but not necessarily support) all features up to that version +MAX_EXTRACT_VERSION = 46 # Below are some formats and associated data for reading/writing headers using # the struct module. The names and structures of headers/records are those used @@ -920,6 +922,9 @@ class ZipFile: (x.create_version, x.create_system, x.extract_version, x.reserved, x.flag_bits, x.compress_type, t, d, x.CRC, x.compress_size, x.file_size) = centdir[1:12] + if x.extract_version > MAX_EXTRACT_VERSION: + raise NotImplementedError("zip file version %.1f" % + (x.extract_version / 10)) x.volume, x.internal_attr, x.external_attr = centdir[15:18] # Convert date/time code to (year, month, day, hour, min, sec) x._raw_time = t |