mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-03 19:45:28 -04:00
Merge pull request #368 from Schmidor/invalidIDFpointer
An invalid IFD pointer caused creating an empty IFD Directory
This commit is contained in:
commit
3f06bbee99
@ -153,7 +153,10 @@ public final class TIFFReader extends MetadataReader {
|
||||
CompoundDirectory next = (CompoundDirectory) readDirectory(pInput, nextOffset, true);
|
||||
|
||||
for (int i = 0; i < next.directoryCount(); i++) {
|
||||
ifds.add((IFD) next.getDirectory(i));
|
||||
if(next.getDirectory(i).size() > 0) {
|
||||
// Linked directories might be empty if nextOffset is after EOF, so skip them
|
||||
ifds.add((IFD) next.getDirectory(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -311,4 +311,13 @@ public class TIFFReaderTest extends MetadataReaderAbstractTest {
|
||||
assertTrue(directory.getEntryById(32934).getValue() instanceof EOFException);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadIDFPointerBeyondEOF() throws IOException {
|
||||
try (ImageInputStream stream = ImageIO.createImageInputStream(getResource("/tiff/ifd-end-pointer.tif"))) {
|
||||
CompoundDirectory directory = (CompoundDirectory) createReader().read(stream);
|
||||
assertEquals(1, directory.directoryCount());
|
||||
assertEquals(15, directory.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user