changeset 34818:0f8792b2b1dc

8144997: "IIOException: Field data is past end-of-stream" when calling TIFFImageReader.read() Summary: Instead of failing for an IFD entry with bad type or offset, continue with the next entry. Reviewed-by: prr
author bpb
date Fri, 11 Dec 2015 15:07:35 -0800
parents 9b585ae27455
children 48fe0e42c65d
files jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java	Fri Dec 11 11:38:18 2015 -0800
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java	Fri Dec 11 15:07:35 2015 -0800
@@ -475,9 +475,10 @@
             int sizeOfType;
             try {
                 sizeOfType = TIFFTag.getSizeOfType(type);
-            } catch (IllegalArgumentException e) {
-                throw new IIOException("Illegal type " + type
-                    + " for tag number " + tagNumber, e);
+            } catch (IllegalArgumentException ignored) {
+                // Continue with the next IFD entry.
+                stream.skipBytes(4);
+                continue;
             }
             int count = (int)stream.readUnsignedInt();
 
@@ -524,7 +525,7 @@
 
                 // Check whether the the field value is within the stream.
                 if (haveStreamLength && offset + size > streamLength) {
-                    throw new IIOException("Field data is past end-of-stream");
+                    continue;
                 }
 
                 // Add a TIFFIFDEntry as a placeholder. This avoids a mark,