MdeModulePkg/BmpSupportLib: Check PixelHeight/PixelWidth against 0

The patch adds check logic to make sure that for a input BMP file,
the width or height is not 0; for a input GOP blt buffer, the width
or height is not 0. Otherwise, UNSUPPORTED status is returned.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Ruiyu Ni 2018-06-25 15:35:06 +08:00
parent 2a9e1b97c9
commit 51fe5b5140
1 changed files with 9 additions and 0 deletions

View File

@ -148,6 +148,11 @@ TranslateBmpToGopBlt (
return RETURN_UNSUPPORTED;
}
if ((BmpHeader->PixelHeight == 0) || (BmpHeader->PixelWidth == 0)) {
DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: BmpHeader->PixelHeight or BmpHeader->PixelWidth is 0.\n"));
return RETURN_UNSUPPORTED;
}
//
// Only support BITMAPINFOHEADER format.
// BITMAPFILEHEADER + BITMAPINFOHEADER = BMP_IMAGE_HEADER
@ -484,6 +489,10 @@ TranslateGopBltToBmp (
return RETURN_INVALID_PARAMETER;
}
if ((PixelHeight == 0) || (PixelWidth == 0)) {
return RETURN_UNSUPPORTED;
}
//
// Allocate memory for BMP file.
//