Merge pull request #217 from Schmidor/tiffreader_eof

Catch EOF at reading IFD pointer
This commit is contained in:
Harald Kuhr 2016-04-21 14:15:08 +02:00
commit ed434dfb1d
3 changed files with 16 additions and 1 deletions

View File

@ -119,7 +119,13 @@ public final class EXIFReader extends MetadataReader {
if (readLinked) {
if (nextOffset == -1) {
nextOffset = pInput.readUnsignedInt();
try {
nextOffset = pInput.readUnsignedInt();
}
catch (EOFException e) {
// catch EOF here as missing EOF marker
nextOffset = 0;
}
}
// Read linked IFDs

View File

@ -276,4 +276,13 @@ public class EXIFReaderTest extends MetadataReaderAbstractTest {
assertNotNull(interop);
assertEquals(0, interop.size());
}
@Test
public void testReadExifWithMissingEOFMarker() throws IOException {
ImageInputStream stream = ImageIO.createImageInputStream(getResource("/exif/noeof.tif"));
CompoundDirectory directory = (CompoundDirectory) createReader().read(stream);
assertEquals(15, directory.size());
assertEquals(1, directory.directoryCount());
stream.close();
}
}