ImageReaderSpi.canDecodeInput sometime throw EOFException
Martin Desruisseaux
martin.desruisseaux at geomatys.com
Thu May 5 10:26:29 UTC 2022
Hello all
Invoking ImageReaderSpi.canDecodeInput(Object) with stream having less
that 8 bytes causes an EOFException to be throw, while the expected
behavior would be for the method to return false. This is caused by BMP,
WBMP, GIF, PNG and TIFF reader implementations which assume that those
bytes always exist and do not check EOF conditions. The JPEG reader is
not impacted.
I have prepared a patch together with a test that 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.
The patch together with the tests are at [1]. Before to submit a pull
request to JDK repository, if I remember correctly from my previous
contribution I think that we need to fill a bug report on JIRA but it
can not be done by myself. Can someone provides some guidance about the
process and things that need to be changed in the proposed patch?
Thanks,
Martin
[1]https://github.com/Geomatys/jdk/commit/c996e83d5899b7ead0f8837aaea4cf991687a20e
More information about the client-libs-dev
mailing list