8267735: Better BMP support

Reviewed-by: prr, rhalade, azvegint, ahgross, mschoene
This commit is contained in:
Jayathirth D V 2021-06-22 12:42:51 +00:00 committed by Henry Jen
parent 3470e7b300
commit c70f7cad47
2 changed files with 8 additions and 0 deletions

View File

@ -591,6 +591,13 @@ public class BMPImageReader extends ImageReader implements BMPConstants {
height = Math.abs(height);
}
if (metadata.compression == BI_RGB) {
long imageDataSize = (width * height * (bitsPerPixel / 8));
if (imageDataSize > (bitmapFileSize - bitmapOffset)) {
throw new IIOException(I18N.getString("BMPImageReader9"));
}
}
// Reset Image Layout so there's only one tile.
//Define the color space
ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);

View File

@ -24,6 +24,7 @@ BMPImageReader5=Input has not been set.
BMPImageReader6=Unable to read the image header.
BMPImageReader7=Invalid bitmap offset.
BMPImageReader8=Invalid bits per pixel in image header.
BMPImageReader9=Invalid width/height for BI_RGB image data.
BMPImageWriter0=Output is not an ImageOutputStream.
BMPImageWriter1=The image region to be encoded is empty.
BMPImageWriter2=Only 1 or 3 band image is encoded.