RFR: 8302151: BMPImageReader throws an exception reading BMP images
Jayathirth D V
jdv at openjdk.org
Wed Feb 15 13:25:44 UTC 2023
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)
-------------
Commit messages:
- 8302151: BMPImageReader throws an exception reading BMP images
Changes: https://git.openjdk.org/jdk/pull/12573/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12573&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8302151
Stats: 68 lines in 2 files changed: 66 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/12573.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/12573/head:pull/12573
PR: https://git.openjdk.org/jdk/pull/12573
More information about the client-libs-dev
mailing list