From a3e2ce543cd9e7c283ef7a44905bbf829e913969 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 11 Dec 2015 15:07:35 -0800 Subject: [PATCH] 8144997: "IIOException: Field data is past end-of-stream" when calling TIFFImageReader.read() Instead of failing for an IFD entry with bad type or offset, continue with the next entry. Reviewed-by: prr --- .../classes/com/sun/imageio/plugins/tiff/TIFFIFD.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java index 7c14f8daf85..e8f4a5d05b3 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/tiff/TIFFIFD.java @@ -475,9 +475,10 @@ public class TIFFIFD extends TIFFDirectory { 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 @@ public class TIFFIFD extends TIFFDirectory { // 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,