MdeModulePkg/BmpSupportLib: Check PixelHeight/PixelWidth against 0
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 25 Jun 2018 07:35:06 +0000 (15:35 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Tue, 3 Jul 2018 03:21:38 +0000 (11:21 +0800)
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>
MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c

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