> -Original Message-
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Zhang, Shenglei
> Sent: Thursday, October 17, 2019 2:21 PM
> To: devel@edk2.groups.io
> Cc: Bi, Dandan ; Dong, Eric
> Subject: [edk2-devel] [PATCH] 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
> Cc: Eric Dong
> Signed-off-by: Shenglei Zhang
> ---
> MdeModulePkg/Universal/HiiDatabaseDxe/Font.c | 7 ++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> index ca63df168c94..282a7a114d17 100644
> --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> @@ -999,7 +999,12 @@ GetSystemFont (
>}
>
>Info->ForegroundColor= mHiiEfiColors[Private->Attribute & 0x0f];
> - Info->BackgroundColor= mHiiEfiColors[Private->Attribute >> 4];
> + if ((Private->Attribute >> 4) < 16){
> +Info->BackgroundColor= mHiiEfiColors[Private->Attribute >> 4];
> + } else {
> +return EFI_INVALID_PARAMETER;
> + }
> +
Hi Shenglei,
Foreground and background color are saved in a single byte. Bits 0..3 are the
foreground color and bits 4..6 are the background color.
If the Private->Attribute defined correctly, then (Private->Attribute >> 4)
must less than 8. And in current code Private->Attribute is defined as
EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK) in HiiDatabaseEntry.c, so the
(Private->Attribute >> 4) will not overflow. I think we can add ASSERT code
instead.
Thanks,
Dandan
>Info->FontInfoMask = EFI_FONT_INFO_SYS_FONT |
> EFI_FONT_INFO_SYS_SIZE | EFI_FONT_INFO_SYS_STYLE;
>Info->FontInfo.FontStyle = 0;
>Info->FontInfo.FontSize = EFI_GLYPH_HEIGHT;
> --
> 2.18.0.windows.1
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#49218): https://edk2.groups.io/g/devel/message/49218
Mute This Topic: https://groups.io/mt/34685172/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-