Skip to content

Commit

Permalink
Fix BLFReader error for incomplete or truncated stream (#1662)
Browse files Browse the repository at this point in the history
* bugfix BLFreader

zlib.error: Error -5 while decompressing data: incomplete or truncated stream in Python

* delete elif

copied on to many lines

* Update blf.py

shorten line -> comment in next line
delete unused variable

* fromatting

---------

Co-authored-by: Iding Robin <[email protected]>
  • Loading branch information
ro-id and Iding Robin authored Sep 17, 2023
1 parent b794153 commit e09d35e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions can/io/blf.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,13 @@ def __iter__(self) -> Generator[Message, None, None]:
self.file.read(obj_size % 4)

if obj_type == LOG_CONTAINER:
method, uncompressed_size = LOG_CONTAINER_STRUCT.unpack_from(obj_data)
method, _ = LOG_CONTAINER_STRUCT.unpack_from(obj_data)
container_data = obj_data[LOG_CONTAINER_STRUCT.size :]
if method == NO_COMPRESSION:
data = container_data
elif method == ZLIB_DEFLATE:
data = zlib.decompress(container_data, 15, uncompressed_size)
zobj = zlib.decompressobj()
data = zobj.decompress(container_data)
else:
# Unknown compression method
LOG.warning("Unknown compression method (%d)", method)
Expand Down

0 comments on commit e09d35e

Please sign in to comment.