[ 
https://issues.apache.org/jira/browse/IMAGING-334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152870#comment-18152870
 ] 

Piotr Karwasz commented on IMAGING-334:
---------------------------------------

The same method also reads past the end of its input when an 
{{is32}}/{{il32}}/{{ih32}}/{{it32}} element is truncated: the loop stops on the 
number of remaining output pixels, not on the remaining input, so a two-byte 
element whose first byte is {{0x80}} (a run of 3 pixels) advances {{dataPos}} 
beyond {{data}} and the next iteration throws 
{{ArrayIndexOutOfBoundsException}}. A fix should bound both the input position 
and the output position, and throw an {{ImagingException}} in both cases.

> ArrayIndexOutOfBoundsException in IcnsDecoder when parsing a broken ICNS file
> -----------------------------------------------------------------------------
>
>                 Key: IMAGING-334
>                 URL: https://issues.apache.org/jira/browse/IMAGING-334
>             Project: Commons Imaging
>          Issue Type: Bug
>          Components: Format: ICNS
>    Affects Versions: 1.0-alpha3
>            Reporter: Dominik Stadler
>            Priority: Major
>              Labels: fuzzer
>         Attachments: ArrayIndexOutOfBoundsException.icon
>
>
> The following snipped throws an ArrayIndexOutOfBoundsException:
> {noformat}
> Imaging.getAllBufferedImages(FileUtils.readFileToByteArray(new 
> File("ArrayIndexOutOfBoundsException.icon"))); {noformat}
>  
> {noformat}
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 
> 65539 out of bounds for length 65536
>     at 
> org.apache.commons.imaging.formats.icns.Rle24Compression.decompress(Rle24Compression.java:51)
>     at 
> org.apache.commons.imaging.formats.icns.IcnsDecoder.decodeImageImpl(IcnsDecoder.java:254)
>     at 
> org.apache.commons.imaging.formats.icns.IcnsDecoder.decodeImage(IcnsDecoder.java:241)
>     at 
> org.apache.commons.imaging.formats.icns.IcnsDecoder.decodeAllImages(IcnsDecoder.java:197)
>     at 
> org.apache.commons.imaging.formats.icns.IcnsImageParser.getAllBufferedImages(IcnsImageParser.java:246)
>     at 
> org.apache.commons.imaging.Imaging.getAllBufferedImages(Imaging.java:758)
>     at 
> org.apache.commons.imaging.Imaging.getAllBufferedImages(Imaging.java:741) 
> {noformat}



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to