Skip to content

Commit e09d35e

Browse files
ro-idIding Robin
andauthored
Fix BLFReader error for incomplete or truncated stream (#1662)
* 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]>
1 parent b794153 commit e09d35e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

can/io/blf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,13 @@ def __iter__(self) -> Generator[Message, None, None]:
182182
self.file.read(obj_size % 4)
183183

184184
if obj_type == LOG_CONTAINER:
185-
method, uncompressed_size = LOG_CONTAINER_STRUCT.unpack_from(obj_data)
185+
method, _ = LOG_CONTAINER_STRUCT.unpack_from(obj_data)
186186
container_data = obj_data[LOG_CONTAINER_STRUCT.size :]
187187
if method == NO_COMPRESSION:
188188
data = container_data
189189
elif method == ZLIB_DEFLATE:
190-
data = zlib.decompress(container_data, 15, uncompressed_size)
190+
zobj = zlib.decompressobj()
191+
data = zobj.decompress(container_data)
191192
else:
192193
# Unknown compression method
193194
LOG.warning("Unknown compression method (%d)", method)

0 commit comments

Comments
 (0)