On Wed, 15 Feb 2023 13:18:31 GMT, Jayathirth D V <[email protected]> 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)

src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java 
line 596:

> 594: 
> 595:         if (metadata.compression == BI_RGB &&
> 596:             metadata.paletteSize == 0 &&

Do we validate the "metadata.paletteSize" in all code paths above or it can be 
substituted to have the wrong value(do we actually trust it)?

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

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

Reply via email to