[OpenJDK 2D-Dev] [10] RFR JDK-8191431: Reading multiple PNG images with unique IDAT chunk positions will cause IIOException
Jayathirth D V
jayathirth.d.v at oracle.com
Mon Nov 20 11:03:42 UTC 2017
Hello All,
Please review the following fix in JDK10 :
Bug : https://bugs.openjdk.java.net/browse/JDK-8191431
Webrev : http://cr.openjdk.java.net/~jdv/8191431/webrev.00/
Issue : When we try to read multiple PNG images with different IDAT chunk positions using the same PNGImageReader instance we get "IIOException: Error reading PNG image data".
Root cause : Issue is happening because of changes present in HYPERLINK "https://bugs.openjdk.java.net/browse/JDK-8164971"JDK-8164971.
Under HYPERLINK "https://bugs.openjdk.java.net/browse/JDK-8164971"JDK-8164971 we have made changes such that imageStartPosition for IDAT chunk will be updated only once for a given PNGImageReader instance while reading metadata.
case IDAT_TYPE:
// If chunk type is 'IDAT', we've reached the image data.
if (imageStartPosition == -1L) {
/*
* PNGs may contain multiple IDAT chunks containing
* a portion of image data. We store the position of
* the first IDAT chunk and continue with iteration
* of other chunks that follow image data.
*/
imageStartPosition = stream.getStreamPosition() - 8;
}
When we use same PNGImageReader instance to read another PNG image and if IDAT chunk position and length differs we will get IIOException.
Solution : We already have resetStreamSettings() method which we call when user tries to decode an image under ImageReader.setInput(). In resetStreamSettings() function if we initialize imageStartPosition to '-1L' it will resolve this issue.
Thanks,
Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20171120/5a0adbc8/attachment.html>
More information about the 2d-dev
mailing list