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.web10.4160.1660206716941839600 for ; Thu, 11 Aug 2022 01:31:57 -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.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M3Kjn29QMzmVgG; Thu, 11 Aug 2022 16:29:49 +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, 11 Aug 2022 16:31:53 +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, 11 Aug 2022 16:31:53 +0800 From: "wenyi,xie" To: , , , , CC: , Subject: [PATCH EDK2 v1 1/1] MdeModulePkg/BaseBmpSupportLib: Fix ColorMap issue Date: Thu, 11 Aug 2022 16:31:46 +0800 Message-ID: <20220811083146.3954530-2-xiewenyi2@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 In-Reply-To: <20220811083146.3954530-1-xiewenyi2@huawei.com> References: <20220811083146.3954530-1-xiewenyi2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.247.83.252] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 --- MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c index c5e885d7a6d5..bea89d530de6 100644 --- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c +++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c @@ -236,6 +236,11 @@ 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