mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 03:55:28 -04:00
An invalid IFD pointer caused creating an empty IFD Directory
This commit is contained in:
parent
86fa76c17d
commit
acad978f71
@ -135,10 +135,13 @@ public final class TIFFReader extends MetadataReader {
|
||||
CompoundDirectory next = (CompoundDirectory) readDirectory(pInput, nextOffset, true);
|
||||
|
||||
for (int i = 0; i < next.directoryCount(); 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Consider leaving to client code what sub-IFDs to parse (but always parse TAG_SUB_IFD).
|
||||
readSubdirectories(pInput, entries,
|
||||
|
@ -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