Optimize code and revise comment

- According to ZIP spec, both uncompressed and compressed size should be 0xffffffff when zip64 is used.
This commit is contained in:
Danny Lin 2025-05-29 01:15:52 +08:00
parent 81a419aaf7
commit c62a4556ff

View file

@ -1619,14 +1619,11 @@ def _validate_local_file_entry(self, fp, offset, end_offset):
# According to the spec, these fields should be zero when data # According to the spec, these fields should be zero when data
# descriptor is used. Otherwise treat as a false positive on # descriptor is used. Otherwise treat as a false positive on
# random bytes to return early, as scanning for data descriptor # random bytes to return early, as scanning for data descriptor
# is rather intensive. # is rather expensive.
if not (zinfo.CRC == zinfo.compress_size == zinfo.file_size == 0): if not (zinfo.CRC == zinfo.compress_size == zinfo.file_size == 0):
return None return None
zip64 = ( zip64 = fheader[_FH_UNCOMPRESSED_SIZE] == 0xffffffff
fheader[_FH_UNCOMPRESSED_SIZE] == 0xffffffff or
fheader[_FH_COMPRESSED_SIZE] == 0xffffffff
)
dd = self._scan_data_descriptor(fp, pos, end_offset, zip64) dd = self._scan_data_descriptor(fp, pos, end_offset, zip64)
if dd is None and not self.strict_descriptor: if dd is None and not self.strict_descriptor: