diff options
author | John Sirois <john.sirois@gmail.com> | 2024-05-07 07:23:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-07 07:23:27 (GMT) |
commit | 49258efada0cb0fc58ccffc018ff310b8f7f4570 (patch) | |
tree | 63671b0c8ea87f6490daee9267534c6c3880e6b9 /Lib/zipimport.py | |
parent | 698417f2f677b7b9373f8a2f202b6c18870bf3c2 (diff) | |
download | cpython-49258efada0cb0fc58ccffc018ff310b8f7f4570.zip cpython-49258efada0cb0fc58ccffc018ff310b8f7f4570.tar.gz cpython-49258efada0cb0fc58ccffc018ff310b8f7f4570.tar.bz2 |
gh-118107: Fix zipimporter ZIP64 handling. (GH-118108)
Add missing import to code that handles too large files and offsets.
Use list, not tuple, for a mutable sequence.
Add tests to prevent similar mistakes.
---------
Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Diffstat (limited to 'Lib/zipimport.py')
-rw-r--r-- | Lib/zipimport.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/zipimport.py b/Lib/zipimport.py index 21d2dca..4e41d10 100644 --- a/Lib/zipimport.py +++ b/Lib/zipimport.py @@ -517,8 +517,9 @@ def _read_directory(archive): num_extra_values = (len(extra_data) - 4) // 8 if num_extra_values > 3: raise ZipImportError(f"can't read header extra: {archive!r}", path=archive) - values = struct.unpack_from(f"<{min(num_extra_values, 3)}Q", - extra_data, offset=4) + import struct + values = list(struct.unpack_from(f"<{min(num_extra_values, 3)}Q", + extra_data, offset=4)) # N.b. Here be dragons: the ordering of these is different than # the header fields, and it's really easy to get it wrong since |