diff options
| author | shadchin <[email protected]> | 2025-06-13 00:05:26 +0300 |
|---|---|---|
| committer | shadchin <[email protected]> | 2025-06-13 00:35:30 +0300 |
| commit | 796b9088366b10b4cd42885101fc20c0b5709b07 (patch) | |
| tree | f287eacb0b95ffd7cabf95b16cafb4788645dc38 /contrib/tools/python3/Lib/zipfile/__init__.py | |
| parent | c72bca862651e507d2ff4980ef7f4ff7267a7227 (diff) | |
Update Python 3 to 3.12.10
commit_hash:dd2398e159fe1d72ea6b12da52fccc933a41a785
Diffstat (limited to 'contrib/tools/python3/Lib/zipfile/__init__.py')
| -rw-r--r-- | contrib/tools/python3/Lib/zipfile/__init__.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/contrib/tools/python3/Lib/zipfile/__init__.py b/contrib/tools/python3/Lib/zipfile/__init__.py index 91b2e032e5f..5d87da6d721 100644 --- a/contrib/tools/python3/Lib/zipfile/__init__.py +++ b/contrib/tools/python3/Lib/zipfile/__init__.py @@ -1490,9 +1490,8 @@ class ZipFile: print("total", total) end_offset = self.start_dir - for zinfo in sorted(self.filelist, - key=lambda zinfo: zinfo.header_offset, - reverse=True): + for zinfo in reversed(sorted(self.filelist, + key=lambda zinfo: zinfo.header_offset)): zinfo._end_offset = end_offset end_offset = zinfo.header_offset @@ -1654,7 +1653,16 @@ class ZipFile: if (zinfo._end_offset is not None and zef_file.tell() + zinfo.compress_size > zinfo._end_offset): - raise BadZipFile(f"Overlapped entries: {zinfo.orig_filename!r} (possible zip bomb)") + if zinfo._end_offset == zinfo.header_offset: + import warnings + warnings.warn( + f"Overlapped entries: {zinfo.orig_filename!r} " + f"(possible zip bomb)", + skip_file_prefixes=(os.path.dirname(__file__),)) + else: + raise BadZipFile( + f"Overlapped entries: {zinfo.orig_filename!r} " + f"(possible zip bomb)") # check for encrypted flag & handle password is_encrypted = zinfo.flag_bits & _MASK_ENCRYPTED |
