RFR: 8302151: BMPImageReader throws an exception reading BMP images

Sergey Bylokhov serb at openjdk.org
Mon Feb 20 18:26:24 UTC 2023


On Wed, 15 Feb 2023 13:18:31 GMT, Jayathirth D V <jdv at openjdk.org> wrote:

> We have check in BMPImageReader, where we verify image data size using BMP file size and bitmap offset value.
> But we can't rely on this calculation when we have color palette. Also color palette is necessary in BMP when bits per pixel is less than 16 according to BMP specification(https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapv4header).
> 
> Now extra checks are added to not perform this check when we have color palette or bpp is less than 16.
> 
> Also when bitsPerPixel was less than 8 it was getting down-casted to 0. So this is also resolved by making this check for >=16bpp and not doing (bitsPerPixel / 8)

Marked as reviewed by serb (Reviewer).

-------------

PR: https://git.openjdk.org/jdk/pull/12573



More information about the client-libs-dev mailing list