Issue2433

classification
Title: zlib decompressobj index error when using negative wbits
Type: behaviour Severity: normal
Components: Library Versions: Jython 2.7
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: lukasa, psykiatris, zyasoft
Priority: high Keywords: easy

Created on 2015-11-23.10:38:23 by lukasa, last changed 2018-04-13.18:21:39 by psykiatris.

Messages
msg10495 (view) Author: Cory Benfield (lukasa) Date: 2015-11-23.10:38:23
When using the zlib module's decompressobj with a negative wbits value (e.g. missing the compressed stream headers), if a sufficiently small amount of data is fed to the decoder for the first chunk, an IndexError will be thrown.

Sample Code:

    import zlib
    data = b'\xcb\xc8T(\xc9H-J\x05\x00'
    d = zlib.decompressobj(-zlib.MAX_WBITS)
    print repr(d.decompress(data[:1]))

Expected result (and the result when using CPython 2.7.10 and PyPy 4.0.0:

    ''

Actual result:

    Traceback (most recent call last):
      File "/Users/cory/tmp/jython_bug.py", line 4, in <module>
        print repr(d.decompress(data[:1]))
      File "/Users/cory/.pyenv/versions/jython-2.7.0/Lib/zlib.py", line 149, in decompress
        string = _skip_gzip_header(string)
      File "/Users/cory/.pyenv/versions/jython-2.7.0/Lib/zlib.py", line 231, in _skip_gzip_header
        id2 = s[1]
    IndexError: index out of range: 1

System Information:


>>> sys.version
'2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11) \n[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)]'
>>> sys.getPlatform()
'java1.8.0_66'

Operating System: Mac OS X 10.11.2 Beta
msg10506 (view) Author: Jim Baker (zyasoft) Date: 2015-11-23.23:11:03
Should be an easy fix, assuming an IndexError always means this underflow problem.
msg11901 (view) Author: Patrick Palczewski (psykiatris) Date: 2018-04-13.18:21:39
I reviewed this issue and verifed that this issue was fixed for Jython 2.7.2. Please closed this issue as fixed.

Output from my versiontest script:
Test python27 ./issue_2433.py passed.
Test jython270 ./issue_2433.py failed.
Test jython272 ./issue_2433.py passed.
History
Date User Action Args
2018-04-13 18:21:39psykiatrissetnosy: + psykiatris
messages: + msg11901
2018-04-10 19:44:33jeff.allensetkeywords: + easy
2015-12-23 20:29:48zyasoftsetpriority: high
2015-11-23 23:11:03zyasoftsetmessages: + msg10506
2015-11-23 21:38:40zyasoftsetnosy: + zyasoft
2015-11-23 10:38:23lukasacreate