[edk2-devel] [PATCH EDK2 v2 1/1] MdeModulePkg/BaseBmpSupportLib: Fix ColorMap issue

Sean spbrogan at outlook.com
Thu Aug 18 04:23:30 UTC 2022


These seem like perfect examples to write host based unit tests for the bmpsupportlib. Then you could run all sorts of different bmp contents thru the lib routines.

Have you thought about adding that

Thanks
Sean
________________________________
From: devel at edk2.groups.io <devel at edk2.groups.io> on behalf of wenyi,xie via groups.io <xiewenyi2=huawei.com at groups.io>
Sent: Wednesday, August 17, 2022 7:26:07 PM
To: devel at edk2.groups.io <devel at edk2.groups.io>; jian.j.wang at intel.com <jian.j.wang at intel.com>; gaoliming at byosoft.com.cn <gaoliming at byosoft.com.cn>; zhichao.gao at intel.com <zhichao.gao at intel.com>; ray.ni at intel.com <ray.ni at intel.com>
Cc: songdongkuang at huawei.com <songdongkuang at huawei.com>; xiewenyi2 at huawei.com <xiewenyi2 at huawei.com>
Subject: [edk2-devel] [PATCH EDK2 v2 1/1] MdeModulePkg/BaseBmpSupportLib: Fix ColorMap issue

When BitPerPixel is 1,4,8, there should be a color map in bmp file. But if
the format of bmp file is error, it maybe has no color map when BitPerPixel
is 1,4,8. The condition checking now can not catch this issue.

Cc: Jian J Wang <jian.j.wang at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Zhichao Gao <zhichao.gao at intel.com>
Cc: Ray Ni <ray.ni at intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2 at huawei.com>
Reviewed-by: Liming Gao <gaoliming at byosoft.com.cn>
---
 MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
index c5e885d7a6d5..1cdd857f48f8 100644
--- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
+++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
@@ -236,6 +236,12 @@ TranslateBmpToGopBlt (
     return RETURN_UNSUPPORTED;
   }

+  if ((BmpHeader->ImageOffset == sizeof (BMP_IMAGE_HEADER)) &&
+      ((BmpHeader->BitPerPixel & 0x0D) != 0))
+  {
+    return RETURN_UNSUPPORTED;
+  }
+
   if (BmpHeader->ImageOffset > sizeof (BMP_IMAGE_HEADER)) {
     switch (BmpHeader->BitPerPixel) {
       case 1:
--
2.20.1.windows.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#92537): https://edk2.groups.io/g/devel/message/92537
Mute This Topic: https://groups.io/mt/93096647/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20220818/605bfe9d/attachment.htm>


More information about the edk2-devel-archive mailing list