public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Dandan Bi" <dandan.bi@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Zhang, Shenglei" <shenglei.zhang@intel.com>
Cc: "Dong, Eric" <eric.dong@intel.com>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4'
Date: Fri, 18 Oct 2019 02:53:10 +0000	[thread overview]
Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB40C7A74D@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20191017062111.10568-1-shenglei.zhang@intel.com>

> -----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 <dandan.bi@intel.com>; Dong, Eric <eric.dong@intel.com>
> 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 <dandan.bi@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
>  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
> 
> 
> 


      parent reply	other threads:[~2019-10-18  2:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17  6:21 [PATCH] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4' Zhang, Shenglei
2019-10-17  6:21 ` [PATCH] MdeModulePkg/SdBlockIoPei: Add check for DeviceIndex Zhang, Shenglei
2019-10-30  7:14   ` [edk2-devel] " Wu, Hao A
2019-10-30  7:53     ` Zhang, Shenglei
2019-10-18  2:53 ` Dandan Bi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C0D5C461C9E904E8F62152F6274C0BB40C7A74D@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox