Piotr Karwasz created IMAGING-407:
-------------------------------------
Summary: ICNS decoder throws ArrayIndexOutOfBoundsException for an
8-bit mask shorter than the image
Key: IMAGING-407
URL: https://issues.apache.org/jira/browse/IMAGING-407
Project: Commons Imaging
Issue Type: Bug
Components: Format: ICNS
Affects Versions: 1.0.0-alpha6
Reporter: Piotr Karwasz
{{IcnsDecoder.apply8BPPMask}} reads {{maskData[y * width + x]}} for every pixel
without checking that the mask element (for example {{s8mk}}) contains {{width
* height}} bytes. An ICNS file pairing a valid {{ics8}} image with a one-byte
{{s8mk}} mask throws {{ArrayIndexOutOfBoundsException}} from
{{Imaging.getBufferedImage}}, instead of an {{ImagingException}}.
The 1-bit variant, {{apply1BPPMask}}, already checks the mask length ({{if
(maskData.length < 2 * totalBytes)}}).
Suggested fix: check {{maskData.length}} against {{width * height}} in
{{apply8BPPMask}} and throw an {{ImagingException}}, as {{apply1BPPMask}} does.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)