Integrated: 8287102: ImageReaderSpi.canDecodeInput() for standard plugins should return false if a stream is too short
Martin Desruisseaux
duke at openjdk.java.net
Fri Jun 3 21:21:35 UTC 2022
On Fri, 13 May 2022 12:23:24 GMT, Martin Desruisseaux <duke at openjdk.java.net> wrote:
> Invoking `ImageReaderSpi.canDecodeInput(Object)` with a stream having less than 8 bytes causes an `EOFException` to be thrown instead of returning `false`. This is caused by BMP, WBMP, GIF, PNG and TIFF reader implementations assuming that those bytes always exist and not checking EOF conditions. The JPEG reader is not impacted.
>
> The `CanDecodeTest` class in this pull request reproduces the problem and verifies that the patch solves it. The changes in `canDecodeInput(Object)` method bodies are:
>
> * Use `ImageInputStream.read()` instead of `readByte()` and check for -1 (EOF) return value.
> * Replace `ImageInputStream.readFully(byte[])` calls by a private `tryReadFully` method.
This pull request has now been integrated.
Changeset: a7e07fdb
Author: Martin Desruisseaux <martin.desruisseaux at geomatys.com>
Committer: Phil Race <prr at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/a7e07fdbc104f668a03d88330e30dbaeb7b43719
Stats: 150 lines in 8 files changed: 129 ins; 9 del; 12 mod
8287102: ImageReaderSpi.canDecodeInput() for standard plugins should return false if a stream is too short
Reviewed-by: prr
-------------
PR: https://git.openjdk.java.net/jdk/pull/8700
More information about the client-libs-dev
mailing list