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
This commit is contained in:
Brian Burkhalter 2015-12-11 15:07:35 -08:00
parent 5b1765f25d
commit a3e2ce543c

View File

@ -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,