Integrated: 8292327: java.io.EOFException in InflaterInputStream after JDK-8281962

Volker Simonis simonis at openjdk.org
Wed Aug 17 09:37:29 UTC 2022


On Mon, 15 Aug 2022 17:43:27 GMT, Volker Simonis <simonis at openjdk.org> wrote:

> The problem is that after [JDK-8281962](https://bugs.openjdk.org/browse/JDK-8281962) we call `fill()` unconditionally (and before calling `Inflater::inflate()`) in `InflaterInputStream::read()` if `Inflater::needsInput()` is true. This misses the case where the native inflater has consumed all its input (i.e. `Inflater::needsInput()` returns true) but hasn't managed to write all the inflated data into the output buffer (e.g. because it was to small). In rare cases, there might be now more input available (i.e. calling `InflaterInputStream::fill()` will throw an `EOFException`) but we still have to call `Inflater::inflate()` to consume the buffered output from the underlying native inflater until inflation stops. 
> 
> The documentation of the `inflate()` method in `zlib.h` mentions this explicitely:
> 
>> "If `inflate()` returns `Z_OK` and with zero `avail_out`, it must be called again after making room in the output buffer because there might be more output pending."

This pull request has now been integrated.

Changeset: 802ef380
Author:    Volker Simonis <simonis at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/802ef38060080254e55621e4c64fa31a6c0b7b18
Stats:     93 lines in 3 files changed: 92 ins; 0 del; 1 mod

8292327: java.io.EOFException in InflaterInputStream after JDK-8281962

Reviewed-by: alanb, lancea

-------------

PR: https://git.openjdk.org/jdk/pull/9881


More information about the core-libs-dev mailing list