diff --git a/unblob/handlers/compression/_gzip_reader.py b/unblob/handlers/compression/_gzip_reader.py index a745b89684..eca36f7f79 100644 --- a/unblob/handlers/compression/_gzip_reader.py +++ b/unblob/handlers/compression/_gzip_reader.py @@ -1,4 +1,5 @@ import gzip +import zlib from ...file_utils import DEFAULT_BUFSIZE @@ -10,6 +11,10 @@ def read_header(self): self._init_read() return self._read_gzip_header() + def _add_read_data(self, data): + self._crc = zlib.crc32(data, self._crc) + self._stream_size = self._stream_size + len(data) + def read(self): uncompress = b"" @@ -17,7 +22,8 @@ def read(self): buf = self._fp.read(DEFAULT_BUFSIZE) uncompress = self._decompressor.decompress(buf, DEFAULT_BUFSIZE) - self._fp.prepend(self._decompressor.unconsumed_tail) + if hasattr(self._decompressor, "unconsumed_tail"): + self._fp.prepend(self._decompressor.unconsumed_tail) self._fp.prepend(self._decompressor.unused_data) if uncompress != b"":