This commit is contained in:
Kovid Goyal 2025-04-08 20:49:52 +05:30
parent 3e1a6e252e
commit c8fbdb110b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -732,11 +732,8 @@ class ZipExtFile(io.BufferedIOBase):
return raw return raw
def check_crc(self, raw: bytes) -> None: def check_crc(self, raw: bytes) -> None:
if self._expected_crc is not None: if self._expected_crc is not None and (crc32(raw) & 0xffffffff) != self._expected_crc:
crc = crc32(raw) & 0xffffffff raise BadZipfile(f'Bad CRC-32 for file {self.name!r}')
# Check the CRC if we're at the end of the file
if crc != self._expected_crc:
raise BadZipfile(f'Bad CRC-32 for file {self.name!r}')
def readall(self): def readall(self):
raw = self.read_raw() raw = self.read_raw()