]> git.proxmox.com Git - mirror_edk2.git/commitdiff
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 2c23e2c61c963fc94e878c5e77accf186987996d..6196262d143b40f8e56eff191dd1d4c6edde1574 100644 (file)
@@ -148,6 +148,11 @@ TranslateBmpToGopBlt (
     return RETURN_UNSUPPORTED;\r
   }\r
 \r
     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
   //\r
   // Only support BITMAPINFOHEADER format.\r
   // BITMAPFILEHEADER + BITMAPINFOHEADER = BMP_IMAGE_HEADER\r
@@ -484,6 +489,10 @@ TranslateGopBltToBmp (
     return RETURN_INVALID_PARAMETER;\r
   }\r
 \r
     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
   //\r
   // Allocate memory for BMP file.\r
   //\r