Piotr Karwasz created IMAGING-401:
-------------------------------------
Summary: TiffReader reads directory chains and nested
sub-directories recursively, causing StackOverflowError
Key: IMAGING-401
URL: https://issues.apache.org/jira/browse/IMAGING-401
Project: Commons Imaging
Issue Type: Bug
Components: Format: TIFF
Affects Versions: 1.0.0-alpha6
Reporter: Piotr Karwasz
{{TiffReader.readDirectory}} calls itself for the next directory of each IFD
and for each EXIF, GPS and interoperability sub-directory, with no limit on the
depth of recursion. The only guard is a list of visited offsets, which stops
loops but not a long chain of distinct offsets. An empty IFD takes 6 bytes, so
a file of about 120 KB with 20,000 chained IFDs makes {{Imaging.getImageInfo}},
{{getMetadata}} or {{getBufferedImage}} fail with a {{StackOverflowError}}. The
same happens with deeply nested EXIF sub-directories. Each level of recursion
also keeps an input stream of the {{ByteSource}} open.
Suggested fix: follow the chain of next directories in a loop, and limit the
nesting depth of sub-directories (the specifications only nest the
interoperability directory inside the EXIF directory). A pull request with the
fix and tests follows.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)