Issue1217

classification
Title: decompressing a malformed stream with zlib results in a java.util.zip.DataFormatException instead of a zlib.error
Type: behaviour Severity: minor
Components: Library Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, njoyce, thijs, zyasoft
Priority: Keywords: patch

Created on 2009-01-02.21:29:41 by njoyce, last changed 2009-01-17.18:35:15 by zyasoft.

Files
File name Uploaded Description Edit Remove
zlib-error-on-decompress.diff njoyce, 2009-01-02.21:29:40 Patch to raise zlib.error instead of java.util.zip.DataFormatException when uncompressing a malformed stream
zlib-error-on-decompress-with-tests.diff njoyce, 2009-01-06.02:03:03
Messages
msg3998 (view) Author: Nick Joyce (njoyce) Date: 2009-01-02.21:29:40
The standard CPython zlib module throws a zlib.error:

>>> import zlib
>>> zlib.decompress('foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
zlib.error: Error -3 while decompressing data: incorrect header check
msg3999 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-01-03.02:44:34
Thanks for reporting the bug and taking a crack at a patch!

If you where to add a test (probably in Lib/test/test_zlib.py) it would
make it much easier for me to accept and apply a patch.

Also, wouldn't it be better to put the try block in _get_inflate_data
since that method gets called in a few places?  And while you are
looking at it _get_deflate_data probably has a similar issue.
msg4002 (view) Author: Nick Joyce (njoyce) Date: 2009-01-06.02:03:03
I have amended the patch to raise the exception in _get_inflate_data instead of 
decompress. I have also added a test to check for the desired behaviour.

I haven't attempted to look at _get_deflate_data because I am not sure that it throws an 
equivalent exception?
msg4053 (view) Author: Jim Baker (zyasoft) Date: 2009-01-17.18:35:15
Fixed in r5938 with the supplied patch by njoyce (2009-01-06). Thanks!

This patch seems of reasonable scope since we should only be seeing this
error on _get_inflate, although we may have other issues in
_get_deflate, likely around resource exhaustion. But that's for another
patch to manage.
History
Date User Action Args
2009-01-17 18:35:15zyasoftsetstatus: open -> closed
resolution: fixed
messages: + msg4053
2009-01-17 17:52:17zyasoftsetnosy: + zyasoft
2009-01-06 02:03:04njoycesetfiles: + zlib-error-on-decompress-with-tests.diff
messages: + msg4002
2009-01-05 10:54:58thijssetnosy: + thijs
2009-01-03 02:44:34fwierzbickisetnosy: + fwierzbicki
messages: + msg3999
2009-01-02 21:29:41njoycecreate