From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mx.groups.io with SMTP id smtpd.web12.37482.1660789593918621063 for ; Wed, 17 Aug 2022 19:26:34 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.187, mailfrom: xiewenyi2@huawei.com) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M7TFV04TNzZfkt; Thu, 18 Aug 2022 10:23:10 +0800 (CST) Received: from kwepemm600004.china.huawei.com (7.193.23.242) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 18 Aug 2022 10:26:13 +0800 Received: from kwephisprg16640.huawei.com (10.247.83.252) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 18 Aug 2022 10:26:12 +0800 From: "wenyi,xie" To: , , , , CC: , Subject: [PATCH EDK2 v2 1/1] MdeModulePkg/BaseBmpSupportLib: Fix ColorMap issue Date: Thu, 18 Aug 2022 10:26:07 +0800 Message-ID: <20220818022607.2528547-2-xiewenyi2@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 In-Reply-To: <20220818022607.2528547-1-xiewenyi2@huawei.com> References: <20220818022607.2528547-1-xiewenyi2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.247.83.252] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected Content-Type: text/plain 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 Cc: Liming Gao Cc: Zhichao Gao Cc: Ray Ni Signed-off-by: Wenyi Xie Reviewed-by: Liming Gao --- 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