Piotr Karwasz created IMAGING-405:
-------------------------------------

             Summary: BMP decoder throws ArrayIndexOutOfBoundsException for a 
pixel index beyond the palette
                 Key: IMAGING-405
                 URL: https://issues.apache.org/jira/browse/IMAGING-405
             Project: Commons Imaging
          Issue Type: Bug
          Components: Format: BMP
    Affects Versions: 1.0.0-alpha6
            Reporter: Piotr Karwasz


The BMP decoder sizes the color table from the header's {{colorsUsed}} value, 
but {{AbstractPixelParser.getColorTableRgb}} uses each pixel value as a palette 
index without checking it against the table length. An 8-bit indexed BMP 
declaring {{colorsUsed = 1}} (a 4-byte color table) with a pixel value of 255 
reads {{colorTable[1020]}} and throws {{ArrayIndexOutOfBoundsException}} from 
{{Imaging.getBufferedImage}}, instead of an {{ImagingException}}.

Suggested fix: check the index against the color table length and throw an 
{{ImagingException}}, or treat out-of-range indices as black, as other decoders 
do; alternatively size the table to 2^bitsPerPixel entries.



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

Reply via email to