mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2025-08-04 03:55: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,10 +153,13 @@ public final class TIFFReader extends MetadataReader {
|
|||||||
CompoundDirectory next = (CompoundDirectory) readDirectory(pInput, nextOffset, true);
|
CompoundDirectory next = (CompoundDirectory) readDirectory(pInput, nextOffset, true);
|
||||||
|
|
||||||
for (int i = 0; i < next.directoryCount(); i++) {
|
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));
|
ifds.add((IFD) next.getDirectory(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Consider leaving to client code what sub-IFDs to parse (but always parse TAG_SUB_IFD).
|
// TODO: Consider leaving to client code what sub-IFDs to parse (but always parse TAG_SUB_IFD).
|
||||||
readSubdirectories(pInput, entries,
|
readSubdirectories(pInput, entries,
|
||||||
|
@ -311,4 +311,13 @@ public class TIFFReaderTest extends MetadataReaderAbstractTest {
|
|||||||
assertTrue(directory.getEntryById(32934).getValue() instanceof EOFException);
|
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