Skip to content

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

Closed
@ro-id

Description

@ro-id

Describe the bug

for larger blf files the Error occurs:
zlib.error: Error -5 while decompressing data: incomplete or truncated stream in Python

To Reproduce

try to read a large blf file

Expected behavior

failure

Additional context

OS and version: Windows 10
Python version: 3.10.12
python-can version: 4.2.2
python-can interface/s (if applicable):

compare to issue https://stackoverflow.com/questions/32367005/zlib-error-error-5-while-decompressing-data-incomplete-or-truncated-stream-in

can be solved by replacing:
(line 189 of con/io/blf.py)

elif method == ZLIB_DEFLATE:
    data = zlib.decompress(container_data, 15, uncompressed_size)

with:
(line 189 of con/io/blf.py)

elif method == ZLIB_DEFLATE:
    zobj = zlib.decompressobj()  # obj for decompressing data streams that won’t fit into memory at once.
    data = zobj.decompress(container_data)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions