[issue12646] zlib.Decompress.decompress/flush do not raise any exceptions when given truncated input streams

Antoine Pitrou report at bugs.python.org
Tue Aug 2 17:38:32 CEST 2011


Antoine Pitrou <pitrou at free.fr> added the comment:

I'm not a zlib specialist, but I think what this means is that the stream is not finished, but it's valid anyway.

For example, you get the same behaviour by doing:

c = zlib.compressobj()
s = c.compress(b'This is just a test string.')
s += c.flush(zlib.Z_FULL_FLUSH)

The resulting bytestring is a non-terminated zlib stream. It still decompresses to the original data fine.

I think the appropriate fix is to add an argument to flush(). Here is a patch, I named the argument "strict" by lack of imagination :)

----------
Added file: http://bugs.python.org/file22828/zlibflushstrict.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12646>
_______________________________________


More information about the Python-bugs-list mailing list