Skip to content

Commit

Permalink
Merge pull request #876 from onekey-sec/fix-unbound-offset
Browse files Browse the repository at this point in the history
fix(zip): handle ZIP64 files missing indicators of ZIP64
  • Loading branch information
kukovecz authored Jun 14, 2024
2 parents 63a8408 + 9f6c60e commit 4d2ba1e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion unblob/handlers/archive/zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def calculate_chunk(self, file: File, start_offset: int) -> Optional[ValidChunk]
has_encrypted_files = False
file.seek(start_offset, io.SEEK_SET)

offset = None
for offset in iterate_patterns(
file, struct.pack("<I", self.EOCD_RECORD_HEADER)
):
Expand All @@ -188,7 +189,9 @@ def calculate_chunk(self, file: File, start_offset: int) -> Optional[ValidChunk]
if offset == end_of_central_directory_offset:
break
else:
# if we can't find 32bit ZIP EOCD, we fall back to ZIP64
if offset is None:
raise InvalidInputFormat("Missing EOCD record header in ZIP chunk.")
# if we can't find a valid 32bit ZIP EOCD, we fall back to ZIP64
end_of_central_directory = self._parse_zip64(file, start_offset, offset)

has_encrypted_files = self.has_encrypted_files(
Expand Down

0 comments on commit 4d2ba1e

Please sign in to comment.