Skip to content

Return only inflated content from Zlib.inflate#6612

Merged
enebo merged 2 commits intojruby:jruby-9.2from
headius:fix_inflate_extra_bytes
Mar 17, 2021
Merged

Return only inflated content from Zlib.inflate#6612
enebo merged 2 commits intojruby:jruby-9.2from
headius:fix_inflate_extra_bytes

Conversation

@headius
Copy link
Member

@headius headius commented Mar 11, 2021

Fixes #6606

Need to investigate the surrounding logic, since it no longer matches CRuby and this patch is a bit of a best guess at what is intended. The basic issue was that we were appending extra bytes on the input to the decompressed output. CRuby, on the other hand, just ensures the input buffer contains only those extra bytes, allowing you to pass the same input to inflate repeatedly to get multiple compressed chunks out of it.

We do not support this behavior, and the related test does not pass (this PR neither fixes nor breaks any CRuby zlib tests, as far as I could see).

@headius headius added this to the JRuby 9.2.17.0 milestone Mar 11, 2021
@headius
Copy link
Member Author

headius commented Mar 11, 2021

Need to dig deeper on this... several specs failed.

headius added 2 commits March 16, 2021 17:05
The finish result will include data that came after the compressed
section from the input. This is appropriate when calling finish to
terminate a previous compressed segment and proceed to the next
segment, but the class-level #inflate should only return the
inflated content.

Fixes jruby#6606
@headius headius force-pushed the fix_inflate_extra_bytes branch from 9b4c615 to f3559c0 Compare March 16, 2021 22:06
@headius headius changed the title Append leftover data to input, not output Return only inflated content from Zlib.inflate Mar 16, 2021
@headius
Copy link
Member Author

headius commented Mar 16, 2021

The new patch is simpler and just returns the inflated content. I believe this matches the MRI behavior better than before. The finish method should still return the post-deflate data from input, but for the class-level Zlib.inflate and Zlib::Inflate.inflate we only return the decompressed content.

@enebo enebo merged commit b32e94c into jruby:jruby-9.2 Mar 17, 2021
@headius headius deleted the fix_inflate_extra_bytes branch March 17, 2021 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants