Skip to content

Commit 8067b0c

Browse files
committed
Fix _scan_data_descriptor
1 parent fef92c4 commit 8067b0c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/zipfile/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,8 +1694,11 @@ def _scan_data_descriptor(self, fp, offset, end_offset, zip64):
16941694
fp, struct.pack('<L', _DD_SIGNATURE), offset, end_offset
16951695
):
16961696
fp.seek(pos)
1697-
dd = fp.read(dd_size)
1698-
_, crc, compress_size, file_size = struct.unpack(dd_fmt, dd)
1697+
dd = fp.read(min(dd_size, end_offset - pos))
1698+
try:
1699+
_, crc, compress_size, file_size = struct.unpack(dd_fmt, dd)
1700+
except struct.error:
1701+
continue
16991702

17001703
# @TODO: also check CRC to better guard from a false positive?
17011704
if pos - offset != compress_size:

0 commit comments

Comments
 (0)