public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4'
@ 2019-10-30 13:45 Zhang, Shenglei
  2019-11-01  2:10 ` Dandan Bi
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang, Shenglei @ 2019-10-30 13:45 UTC (permalink / raw)
  To: devel; +Cc: Dandan Bi, Eric Dong

The size of mHiiEfiColors is 16.
mHiiEfiColors[Private->Attribute >> 4] may be out of boundary.
So add a check for that.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
v2: Instead of returing value, we add ASSERT to ensure
    "Private->Attribute >> 4" is not out of boundary.

 MdeModulePkg/Universal/HiiDatabaseDxe/Font.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
index ca63df168c94..1eee5ec76bb0 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
@@ -999,6 +999,7 @@ GetSystemFont (
   }
 
   Info->ForegroundColor    = mHiiEfiColors[Private->Attribute & 0x0f];
+  ASSERT ((Private->Attribute >> 4) < 16);
   Info->BackgroundColor    = mHiiEfiColors[Private->Attribute >> 4];
   Info->FontInfoMask       = EFI_FONT_INFO_SYS_FONT | EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_SYS_STYLE;
   Info->FontInfo.FontStyle = 0;
-- 
2.18.0.windows.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4'
  2019-10-30 13:45 [PATCH v2] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4' Zhang, Shenglei
@ 2019-11-01  2:10 ` Dandan Bi
  0 siblings, 0 replies; 2+ messages in thread
From: Dandan Bi @ 2019-11-01  2:10 UTC (permalink / raw)
  To: Zhang, Shenglei, devel@edk2.groups.io; +Cc: Dong, Eric

> -----Original Message-----
> From: Zhang, Shenglei
> Sent: Wednesday, October 30, 2019 9:46 PM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan <dandan.bi@intel.com>; Dong, Eric <eric.dong@intel.com>
> Subject: [PATCH v2] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private-
> >Attribute >> 4'
> 
> The size of mHiiEfiColors is 16.
> mHiiEfiColors[Private->Attribute >> 4] may be out of boundary.
> So add a check for that.
> 
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
> v2: Instead of returing value, we add ASSERT to ensure
>     "Private->Attribute >> 4" is not out of boundary.
> 
>  MdeModulePkg/Universal/HiiDatabaseDxe/Font.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> index ca63df168c94..1eee5ec76bb0 100644
> --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> @@ -999,6 +999,7 @@ GetSystemFont (
>    }
> 
>    Info->ForegroundColor    = mHiiEfiColors[Private->Attribute & 0x0f];
> +  ASSERT ((Private->Attribute >> 4) < 16);

Hi Shenglei,
1) I think we can add ASSERT ((Private->Attribute >> 4) < 8); here directly, the reason can refer my comments in V1 patch.
2) And please also update the subject and commit message accordingly.
With  above comments addressed, Reviewed-by: Dandan Bi <dandan.bi@intel.com>

Thanks,
Dandan
>    Info->BackgroundColor    = mHiiEfiColors[Private->Attribute >> 4];
>    Info->FontInfoMask       = EFI_FONT_INFO_SYS_FONT |
> EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_SYS_STYLE;
>    Info->FontInfo.FontStyle = 0;
> --
> 2.18.0.windows.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-11-01  2:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-30 13:45 [PATCH v2] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4' Zhang, Shenglei
2019-11-01  2:10 ` Dandan Bi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox