RFR: 7036144: GZIPInputStream readTrailer uses faulty available() test for end-of-stream

Archie Cobbs acobbs at openjdk.org
Thu Dec 14 20:46:03 UTC 2023


`GZIPInputStream`, when looking for a concatenated stream, relies on what the underlying `InputStream` says is how many bytes are `available()`. But this is inappropriate because `InputStream.available()` is just an estimate and is allowed (for example) to always return zero.

The fix is to ignore what's `available()` and just proceed and see what happens. If fewer bytes are available than required, the attempt to extend to another stream is canceled just as it was before, e.g., when the next stream header couldn't be read.

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

Commit messages:
 - Fix bug in GZIPInputStream when underlying available() returns short.

Changes: https://git.openjdk.org/jdk/pull/17113/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17113&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-7036144
  Stats: 101 lines in 2 files changed: 86 ins; 9 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/17113.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17113/head:pull/17113

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


More information about the core-libs-dev mailing list