On Fri, 13 May 2022 12:23:24 GMT, Martin Desruisseaux <d...@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. test/jdk/javax/imageio/plugins/shared/CanDecodeTest.java line 49: > 47: ImageReader reader = > 48: ImageIO.getImageReadersByFormatName("BMP").next(); > 49: ImageReaderSpi spi = reader.getOriginatingProvider(); Isn't that supposed to have format, not "BMP" as the arg ? ------------- PR: https://git.openjdk.java.net/jdk/pull/8700