[EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data


Bret Barkelew
 

Is this a *good* idea?

 

What is considered valid extra data? If it’s immaterial to the FW displaying the image, our policy has been to strip it off BEFORE adding it to the FW image.

 

- Bret

 

From: Jeff Brasen via groups.io
Sent: Tuesday, March 23, 2021 10:29 AM
To: devel@edk2.groups.io
Cc: jian.j.wang@...; ao.a.wu@...; Jeff Brasen
Subject: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data

 

Add support for processing BMP data that contains extra data after the
image array, this data will not be parsed in anyway in the library but
images that contain this will not be rejected from processing.

---
 MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
index 3ac31f6723d0..944d01fe7cdf 100644
--- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
+++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
@@ -213,7 +213,7 @@ TranslateBmpToGopBlt (
 
   if ((BmpHeader->Size != BmpImageSize) ||
       (BmpHeader->Size < BmpHeader->ImageOffset) ||
-      (BmpHeader->Size - BmpHeader->ImageOffset != DataSize)) {
+      (BmpHeader->Size - BmpHeader->ImageOffset < DataSize)) {
 
     DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: invalid BmpImage... \n"));
     DEBUG ((DEBUG_ERROR, "   BmpHeader->Size: 0x%x\n", BmpHeader->Size));
--
2.25.1





 


Laszlo Ersek
 

On 03/23/21 18:41, Bret Barkelew via groups.io wrote:
Is this a *good* idea?

What is considered valid extra data? If it’s immaterial to the FW displaying the image, our policy has been to strip it off BEFORE adding it to the FW image.
Not counting any potential security aspects, stripping out undisplayed
portions helps with flash usage too (I think?), so at least some
concrete justification in the commit message would be nice...

Thanks
Laszlo


- Bret

From: Jeff Brasen via groups.io<mailto:jbrasen=nvidia.com@groups.io>
Sent: Tuesday, March 23, 2021 10:29 AM
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: jian.j.wang@intel.com<mailto:jian.j.wang@intel.com>; ao.a.wu@intel.com<mailto:ao.a.wu@intel.com>; Jeff Brasen<mailto:jbrasen@nvidia.com>
Subject: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data

Add support for processing BMP data that contains extra data after the
image array, this data will not be parsed in anyway in the library but
images that contain this will not be rejected from processing.

---
MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
index 3ac31f6723d0..944d01fe7cdf 100644
--- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
+++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
@@ -213,7 +213,7 @@ TranslateBmpToGopBlt (

if ((BmpHeader->Size != BmpImageSize) ||
(BmpHeader->Size < BmpHeader->ImageOffset) ||
- (BmpHeader->Size - BmpHeader->ImageOffset != DataSize)) {
+ (BmpHeader->Size - BmpHeader->ImageOffset < DataSize)) {

DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: invalid BmpImage... \n"));
DEBUG ((DEBUG_ERROR, " BmpHeader->Size: 0x%x\n", BmpHeader->Size));
--
2.25.1












Jeff Brasen
 

Some of the logo files we received for the group that makes our assets like this (not sure what tool they were created with) look like they pad the BMP size to 8 bytes.

TranslateBmpToGopBlt: invalid BmpImage...
   BmpHeader->Size: 0xE1038
   BmpHeader->ImageOffset: 0x36
   BmpImageSize: 0xE1038
   DataSize: 0xE1000
TranslateBmpToGopBlt: invalid BmpImage...
   BmpHeader->Size: 0x2A3038
   BmpHeader->ImageOffset: 0x36
   BmpImageSize: 0x2A3038
   DataSize: 0x2A3000
TranslateBmpToGopBlt: invalid BmpImage...
   BmpHeader->Size: 0x5EEC38
   BmpHeader->ImageOffset: 0x36
   BmpImageSize: 0x5EEC38
   DataSize: 0x5EEC00

So, each of these has 2 bytes of padding at the end of the file. We could write a tool that would do the same size recalculation in order to update the size in the header and remove the two bytes but it seems that this is a valid BMP file and it doesn't seem correct that UEFI is rejecting it. I can update the commit message with more context if needed as well.

Thanks,

Jeff


From: Laszlo Ersek <lersek@...>
Sent: Wednesday, March 24, 2021 5:31 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>; bret.barkelew@... <bret.barkelew@...>; Jeff Brasen <jbrasen@...>
Cc: jian.j.wang@... <jian.j.wang@...>; ao.a.wu@... <ao.a.wu@...>
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data
 
External email: Use caution opening links or attachments


On 03/23/21 18:41, Bret Barkelew via groups.io wrote:
> Is this a *good* idea?
>
> What is considered valid extra data? If it’s immaterial to the FW displaying the image, our policy has been to strip it off BEFORE adding it to the FW image.

Not counting any potential security aspects, stripping out undisplayed
portions helps with flash usage too (I think?), so at least some
concrete justification in the commit message would be nice...

Thanks
Laszlo

>
> - Bret
>
> From: Jeff Brasen via groups.io<mailto:jbrasen@...>
> Sent: Tuesday, March 23, 2021 10:29 AM
> To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
> Cc: jian.j.wang@...<mailto:jian.j.wang@...>; ao.a.wu@...<mailto:ao.a.wu@...>; Jeff Brasen<mailto:jbrasen@...>
> Subject: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data
>
> Add support for processing BMP data that contains extra data after the
> image array, this data will not be parsed in anyway in the library but
> images that contain this will not be rejected from processing.
>
> ---
>  MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
> index 3ac31f6723d0..944d01fe7cdf 100644
> --- a/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
> +++ b/MdeModulePkg/Library/BaseBmpSupportLib/BmpSupportLib.c
> @@ -213,7 +213,7 @@ TranslateBmpToGopBlt (
>
>    if ((BmpHeader->Size != BmpImageSize) ||
>        (BmpHeader->Size < BmpHeader->ImageOffset) ||
> -      (BmpHeader->Size - BmpHeader->ImageOffset != DataSize)) {
> +      (BmpHeader->Size - BmpHeader->ImageOffset < DataSize)) {
>
>      DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: invalid BmpImage... \n"));
>      DEBUG ((DEBUG_ERROR, "   BmpHeader->Size: 0x%x\n", BmpHeader->Size));
> --
> 2.25.1
>
>
>
>
>
>
>
>
>
>
>
>


Laszlo Ersek
 

On 03/24/21 16:25, Jeff Brasen wrote:
Some of the logo files we received for the group that makes our assets like this (not sure what tool they were created with) look like they pad the BMP size to 8 bytes.

TranslateBmpToGopBlt: invalid BmpImage...
BmpHeader->Size: 0xE1038
BmpHeader->ImageOffset: 0x36
BmpImageSize: 0xE1038
DataSize: 0xE1000
TranslateBmpToGopBlt: invalid BmpImage...
BmpHeader->Size: 0x2A3038
BmpHeader->ImageOffset: 0x36
BmpImageSize: 0x2A3038
DataSize: 0x2A3000
TranslateBmpToGopBlt: invalid BmpImage...
BmpHeader->Size: 0x5EEC38
BmpHeader->ImageOffset: 0x36
BmpImageSize: 0x5EEC38
DataSize: 0x5EEC00

So, each of these has 2 bytes of padding at the end of the file. We could write a tool that would do the same size recalculation in order to update the size in the header and remove the two bytes but it seems that this is a valid BMP file and it doesn't seem correct that UEFI is rejecting it. I can update the commit message with more context if needed as well.
If there's a spec describing the BMP format, and edk2 is needlessly
strict, and the check can be relaxed without security risks, then I
think a patch would be fair.

Thanks
Laszlo


Andrew Fish
 



On Mar 24, 2021, at 11:26 AM, Laszlo Ersek <lersek@...> wrote:

On 03/24/21 16:25, Jeff Brasen wrote:
Some of the logo files we received for the group that makes our assets like this (not sure what tool they were created with) look like they pad the BMP size to 8 bytes.

TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0xE1038
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0xE1038
  DataSize: 0xE1000
TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0x2A3038
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0x2A3038
  DataSize: 0x2A3000
TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0x5EEC38
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0x5EEC38
  DataSize: 0x5EEC00

So, each of these has 2 bytes of padding at the end of the file. We could write a tool that would do the same size recalculation in order to update the size in the header and remove the two bytes but it seems that this is a valid BMP file and it doesn't seem correct that UEFI is rejecting it. I can update the commit message with more context if needed as well.

If there's a spec describing the BMP format,

Yes and there are various flavors as at some point I had some graphics given to me in a format that did not work (I think it was BITMAPV4HEADER) :(. 


edk2 supports ‘BM’ and the BITMAPINFOHEADER DIB. I seem to remember DIBs are defined by the size. So ‘BM' is a Microsoft Spec:

The quote in that spec is:

The file extension of a Windows DIB file is BMP. The file consists of a BITMAPFILEHEADER structure followed by the DIB itself. Unfortunately, because the BITMAPFILEHEADER structure is never actually passed to the API, not every application that generates BMP files fills out the data structure carefully. To add to this confusion, the "proper" definition of the structure is at odds with the documentation. Properly, the data structure contains the following fields:

The explanation of size field is:
DWORD that specifies the size of the file in bytes. The Microsoft Windows Software Development Kit (SDK) documentation claims otherwise. To be on the safe side, many applications calculate their own sizes for reading in a file.

I would say that is not exactly a ringing endorsement from a spec point of view on depending on that field. So it seems like that patch may be reasonable, but we should triple check it does not break any security related assumptions. 

Thanks,

Andrew Fish

and edk2 is needlessly
strict, and the check can be relaxed without security risks, then I
think a patch would be fair.

Thanks
Laszlo





Gao, Zhichao
 

The patch would let the BMP file that with a bunch of data pass the check, no matter the data is valid or not. Do we have other docs to descript which data is allowed and valid?

 

Correct the Cc mail address and invite more experts for security review.

 

Thanks,

Zhichao

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Andrew Fish via groups.io
Sent: Thursday, March 25, 2021 11:00 AM
To: edk2-devel-groups-io <devel@edk2.groups.io>; Laszlo Ersek <lersek@...>
Cc: Jeff Brasen <jbrasen@...>; bret.barkelew@...; Wang, Jian J <jian.j.wang@...>; ao.a.wu@...
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data

 

 



On Mar 24, 2021, at 11:26 AM, Laszlo Ersek <lersek@...> wrote:

 

On 03/24/21 16:25, Jeff Brasen wrote:

Some of the logo files we received for the group that makes our assets like this (not sure what tool they were created with) look like they pad the BMP size to 8 bytes.

TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0xE1038
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0xE1038
  DataSize: 0xE1000
TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0x2A3038
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0x2A3038
  DataSize: 0x2A3000
TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0x5EEC38
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0x5EEC38
  DataSize: 0x5EEC00

So, each of these has 2 bytes of padding at the end of the file. We could write a tool that would do the same size recalculation in order to update the size in the header and remove the two bytes but it seems that this is a valid BMP file and it doesn't seem correct that UEFI is rejecting it. I can update the commit message with more context if needed as well.


If there's a spec describing the BMP format,

 

Yes and there are various flavors as at some point I had some graphics given to me in a format that did not work (I think it was BITMAPV4HEADER) :(. 

 

 

edk2 supports ‘BM’ and the BITMAPINFOHEADER DIB. I seem to remember DIBs are defined by the size. So ‘BM' is a Microsoft Spec:

 

The quote in that spec is:

 

The file extension of a Windows DIB file is BMP. The file consists of a BITMAPFILEHEADER structure followed by the DIB itself. Unfortunately, because the BITMAPFILEHEADER structure is never actually passed to the API, not every application that generates BMP files fills out the data structure carefully. To add to this confusion, the "proper" definition of the structure is at odds with the documentation. Properly, the data structure contains the following fields:



The explanation of size field is:

DWORD that specifies the size of the file in bytes. The Microsoft Windows Software Development Kit (SDK) documentation claims otherwise. To be on the safe side, many applications calculate their own sizes for reading in a file.

 

I would say that is not exactly a ringing endorsement from a spec point of view on depending on that field. So it seems like that patch may be reasonable, but we should triple check it does not break any security related assumptions. 

 

Thanks,

 

Andrew Fish



and edk2 is needlessly
strict, and the check can be relaxed without security risks, then I
think a patch would be fair.

Thanks
Laszlo




 


Bret Barkelew
 

I agree with the proposal for a deeper security review.

 

I also would suggest that we can provide tooling with BaseTools to check and/or correct the format of a BMP to match what the code expects (since there seems to be ambiguity in the spec/implementation). We’ve got a validator in Mu and would be happy to put together some patches to at least get this started for the community to hammer on.

 

- Bret

 

From: Gao, Zhichao via groups.io
Sent: Monday, March 29, 2021 6:35 PM
To: devel@edk2.groups.io; afish@...; Laszlo Ersek
Cc: Jeff Brasen; Bret Barkelew; Wang, Jian J; Wu, Hao A; Yao, Jiewen; Liming Gao; Ni, Ray
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data

 

The patch would let the BMP file that with a bunch of data pass the check, no matter the data is valid or not. Do we have other docs to descript which data is allowed and valid?

 

Correct the Cc mail address and invite more experts for security review.

 

Thanks,

Zhichao

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Andrew Fish via groups.io
Sent: Thursday, March 25, 2021 11:00 AM
To: edk2-devel-groups-io <devel@edk2.groups.io>; Laszlo Ersek <lersek@...>
Cc: Jeff Brasen <jbrasen@...>; bret.barkelew@...; Wang, Jian J <jian.j.wang@...>; ao.a.wu@...
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data

 

 

 

On Mar 24, 2021, at 11:26 AM, Laszlo Ersek <lersek@...> wrote:

 

On 03/24/21 16:25, Jeff Brasen wrote:

Some of the logo files we received for the group that makes our assets like this (not sure what tool they were created with) look like they pad the BMP size to 8 bytes.

TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0xE1038
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0xE1038
  DataSize: 0xE1000
TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0x2A3038
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0x2A3038
  DataSize: 0x2A3000
TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0x5EEC38
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0x5EEC38
  DataSize: 0x5EEC00

So, each of these has 2 bytes of padding at the end of the file. We could write a tool that would do the same size recalculation in order to update the size in the header and remove the two bytes but it seems that this is a valid BMP file and it doesn't seem correct that UEFI is rejecting it. I can update the commit message with more context if needed as well.


If there's a spec describing the BMP format,

 

Yes and there are various flavors as at some point I had some graphics given to me in a format that did not work (I think it was BITMAPV4HEADER) :(. 

 

 

edk2 supports ‘BM’ and the BITMAPINFOHEADER DIB. I seem to remember DIBs are defined by the size. So ‘BM' is a Microsoft Spec:

 

The quote in that spec is:

 

The file extension of a Windows DIB file is BMP. The file consists of a BITMAPFILEHEADER structure followed by the DIB itself. Unfortunately, because the BITMAPFILEHEADER structure is never actually passed to the API, not every application that generates BMP files fills out the data structure carefully. To add to this confusion, the "proper" definition of the structure is at odds with the documentation. Properly, the data structure contains the following fields:

 

The explanation of size field is:

DWORD that specifies the size of the file in bytes. The Microsoft Windows Software Development Kit (SDK) documentation claims otherwise. To be on the safe side, many applications calculate their own sizes for reading in a file.

 

I would say that is not exactly a ringing endorsement from a spec point of view on depending on that field. So it seems like that patch may be reasonable, but we should triple check it does not break any security related assumptions. 

 

Thanks,

 

Andrew Fish

 

and edk2 is needlessly
strict, and the check can be relaxed without security risks, then I
think a patch would be fair.

Thanks
Laszlo



 

 


Jeff Brasen
 

Sorry I was out for a bit so didn't get back to this thread for a bit. Who should be on any additional security review?

In TranslateBmpToGopBlt the Size is only used in DEBUG prints and this verification check. Processing of the data uses the image structure data. In addition BMP that have extra data between the color map (if present right after bmp header) and the image data is allowed with an explicit comment.

    //
    // BMP file may has padding data between the bmp header section and the
    // bmp data section.
    //
    if (BmpHeader->ImageOffset - sizeof (BMP_IMAGE_HEADER) < sizeof (BMP_COLOR_MAP) * ColorMapNum) {
      return RETURN_UNSUPPORTED;
    }

Thanks,

Jeff


From: Bret Barkelew <Bret.Barkelew@...>
Sent: Thursday, April 1, 2021 11:37 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>; zhichao.gao@... <zhichao.gao@...>; afish@... <afish@...>; Laszlo Ersek <lersek@...>
Cc: Jeff Brasen <jbrasen@...>; Wang, Jian J <jian.j.wang@...>; Wu, Hao A <hao.a.wu@...>; Yao, Jiewen <jiewen.yao@...>; Liming Gao <gaoliming@...>; Ni, Ray <ray.ni@...>
Subject: RE: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data
 
External email: Use caution opening links or attachments

I agree with the proposal for a deeper security review.

 

I also would suggest that we can provide tooling with BaseTools to check and/or correct the format of a BMP to match what the code expects (since there seems to be ambiguity in the spec/implementation). We’ve got a validator in Mu and would be happy to put together some patches to at least get this started for the community to hammer on.

 

- Bret

 

From: Gao, Zhichao via groups.io
Sent: Monday, March 29, 2021 6:35 PM
To: devel@edk2.groups.io; afish@...; Laszlo Ersek
Cc: Jeff Brasen; Bret Barkelew; Wang, Jian J; Wu, Hao A; Yao, Jiewen; Liming Gao; Ni, Ray
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data

 

The patch would let the BMP file that with a bunch of data pass the check, no matter the data is valid or not. Do we have other docs to descript which data is allowed and valid?

 

Correct the Cc mail address and invite more experts for security review.

 

Thanks,

Zhichao

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Andrew Fish via groups.io
Sent: Thursday, March 25, 2021 11:00 AM
To: edk2-devel-groups-io <devel@edk2.groups.io>; Laszlo Ersek <lersek@...>
Cc: Jeff Brasen <jbrasen@...>; bret.barkelew@...; Wang, Jian J <jian.j.wang@...>; ao.a.wu@...
Subject: Re: [EXTERNAL] [edk2-devel] [PATCH 1/1] MdeModulePkg/BmpSupportLib: Allow BMP with extra data

 

 

 

On Mar 24, 2021, at 11:26 AM, Laszlo Ersek <lersek@...> wrote:

 

On 03/24/21 16:25, Jeff Brasen wrote:

Some of the logo files we received for the group that makes our assets like this (not sure what tool they were created with) look like they pad the BMP size to 8 bytes.

TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0xE1038
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0xE1038
  DataSize: 0xE1000
TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0x2A3038
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0x2A3038
  DataSize: 0x2A3000
TranslateBmpToGopBlt: invalid BmpImage...
  BmpHeader->Size: 0x5EEC38
  BmpHeader->ImageOffset: 0x36
  BmpImageSize: 0x5EEC38
  DataSize: 0x5EEC00

So, each of these has 2 bytes of padding at the end of the file. We could write a tool that would do the same size recalculation in order to update the size in the header and remove the two bytes but it seems that this is a valid BMP file and it doesn't seem correct that UEFI is rejecting it. I can update the commit message with more context if needed as well.


If there's a spec describing the BMP format,

 

Yes and there are various flavors as at some point I had some graphics given to me in a format that did not work (I think it was BITMAPV4HEADER) :(. 

 

 

edk2 supports ‘BM’ and the BITMAPINFOHEADER DIB. I seem to remember DIBs are defined by the size. So ‘BM' is a Microsoft Spec:

 

The quote in that spec is:

 

The file extension of a Windows DIB file is BMP. The file consists of a BITMAPFILEHEADER structure followed by the DIB itself. Unfortunately, because the BITMAPFILEHEADER structure is never actually passed to the API, not every application that generates BMP files fills out the data structure carefully. To add to this confusion, the "proper" definition of the structure is at odds with the documentation. Properly, the data structure contains the following fields:

 

The explanation of size field is:

DWORD that specifies the size of the file in bytes. The Microsoft Windows Software Development Kit (SDK) documentation claims otherwise. To be on the safe side, many applications calculate their own sizes for reading in a file.

 

I would say that is not exactly a ringing endorsement from a spec point of view on depending on that field. So it seems like that patch may be reasonable, but we should triple check it does not break any security related assumptions. 

 

Thanks,

 

Andrew Fish

 

and edk2 is needlessly
strict, and the check can be relaxed without security risks, then I
think a patch would be fair.

Thanks
Laszlo