Fabian Meumertzheim created IMAGING-276:
-------------------------------------------
Summary: ArrayIndexOutOfBoundsException in TiffDirectory
Key: IMAGING-276
URL: https://issues.apache.org/jira/browse/IMAGING-276
Project: Commons Imaging
Issue Type: Bug
Components: Format: TIFF
Affects Versions: 1.0-alpha2
Reporter: Fabian Meumertzheim
Attachments: TiffImageParserCrash.java
The following Java snippet crashes with an ArrayIndexOutOfBoundsException:
{code:java}
import java.io.IOException;
import java.util.Base64;
import java.util.HashMap;
import org.apache.commons.imaging.ImageReadException;
import org.apache.commons.imaging.common.bytesource.ByteSourceArray;
import org.apache.commons.imaging.formats.tiff.TiffImageParser;
public class TiffImageParserCrash {
public static byte[] btoa(String base64) {
return Base64.getDecoder().decode(base64);
}
public static void main(String[] args) {
byte[] input =
btoa("SUkqAAoAAAACAgIAAQIIAAAAAADNAAICAgICAAAAAAAA////////CQ==");
try {
new TiffImageParser().getBufferedImage(new ByteSourceArray(input),
new HashMap<>());
} catch (IOException | ImageReadException e) {}
}
}
{code}
The stack trace is:
{noformat}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0
out of bounds for length 0
at
org.apache.commons.imaging.formats.tiff.TiffDirectory.getJpegRawImageDataElement(TiffDirectory.java:859)
at
org.apache.commons.imaging.formats.tiff.TiffReader.getJpegRawImageData(TiffReader.java:485)
at
org.apache.commons.imaging.formats.tiff.TiffReader.readDirectory(TiffReader.java:219)
at
org.apache.commons.imaging.formats.tiff.TiffReader.readDirectory(TiffReader.java:115)
at
org.apache.commons.imaging.formats.tiff.TiffReader.readDirectories(TiffReader.java:108)
at
org.apache.commons.imaging.formats.tiff.TiffReader.read(TiffReader.java:419)
at
org.apache.commons.imaging.formats.tiff.TiffReader.readFirstDirectory(TiffReader.java:382)
at
org.apache.commons.imaging.formats.tiff.TiffImageParser.getBufferedImage(TiffImageParser.java:465)
at TiffImageParserCrash.main(TiffImageParserCrash.java:17)
{noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)