[OpenJDK 2D-Dev] [10] RFR JDK-8191431: Reading multiple PNG images with unique IDAT chunk positions will cause IIOException

Prahalad Kumar Narayanan prahalad.kumar.narayanan at oracle.com
Mon Nov 20 11:54:43 UTC 2017


Hello Jay

The code change at PNGImageReader is correct.
But the test wouldn't delete temporary files when exception occurs.

Thank you
Have a good day

Prahalad

----- Original Message -----
From: Jayathirth D V 
Sent: Monday, November 20, 2017 4:34 PM
To: 2d-dev
Subject: [OpenJDK 2D-Dev] [10] RFR JDK-8191431: Reading multiple PNG images with unique IDAT chunk positions will cause IIOException

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 JDK-8164971.
                Under 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


More information about the 2d-dev mailing list