public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wang, Jian J" <jian.j.wang@intel.com>
To: "Jiang, Guomin" <guomin.jiang@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Wu, Hao A" <hao.a.wu@intel.com>,
	"Dong, Eric" <eric.dong@intel.com>, "Ni, Ray" <ray.ni@intel.com>
Subject: Re: [PATCH v2] MdeModulePkg/SmiHandlerProfileInfo: Overflowed Array Index
Date: Fri, 3 Apr 2020 04:32:52 +0000	[thread overview]
Message-ID: <D827630B58408649ACB04F44C510003625A4296C@SHSMSX107.ccr.corp.intel.com> (raw)
In-Reply-To: <20200403042431.1299-1-guomin.jiang@intel.com>


Reviewed-by: Jian J Wang <jian.j.wang@intel.com>

Regards,
Jian

> -----Original Message-----
> From: Jiang, Guomin <guomin.jiang@intel.com>
> Sent: Friday, April 03, 2020 12:25 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>
> Subject: [PATCH v2] MdeModulePkg/SmiHandlerProfileInfo: Overflowed Array
> Index
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2272
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2287
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2288
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2289
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2290
> 
> Index should be off-by one than size of array, so when check
> array, the max index should less than size of array.
> 
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Guomin Jiang <guomin.jiang@intel.com>
> ---
>  .../SmiHandlerProfileInfo/SmiHandlerProfileInfo.c    | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
> b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
> index 0f7163160b..4153074b7a 100644
> ---
> a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
> +++
> b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
> @@ -382,7 +382,7 @@ SxTypeToString (
>    IN EFI_SLEEP_TYPE  Type
> 
>    )
> 
>  {
> 
> -  if (Type >= 0 && Type <= ARRAY_SIZE(mSxTypeString)) {
> 
> +  if (Type >= 0 && Type < ARRAY_SIZE(mSxTypeString)) {
> 
>      return mSxTypeString[Type];
> 
>    } else {
> 
>      AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);
> 
> @@ -407,7 +407,7 @@ SxPhaseToString (
>    IN EFI_SLEEP_PHASE Phase
> 
>    )
> 
>  {
> 
> -  if (Phase >= 0 && Phase <= ARRAY_SIZE(mSxPhaseString)) {
> 
> +  if (Phase >= 0 && Phase < ARRAY_SIZE(mSxPhaseString)) {
> 
>      return mSxPhaseString[Phase];
> 
>    } else {
> 
>      AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);
> 
> @@ -432,7 +432,7 @@ PowerButtonPhaseToString (
>    IN EFI_POWER_BUTTON_PHASE  Phase
> 
>    )
> 
>  {
> 
> -  if (Phase >= 0 && Phase <= ARRAY_SIZE(mPowerButtonPhaseString)) {
> 
> +  if (Phase >= 0 && Phase < ARRAY_SIZE(mPowerButtonPhaseString)) {
> 
>      return mPowerButtonPhaseString[Phase];
> 
>    } else {
> 
>      AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);
> 
> @@ -457,7 +457,7 @@ StandbyButtonPhaseToString (
>    IN EFI_STANDBY_BUTTON_PHASE  Phase
> 
>    )
> 
>  {
> 
> -  if (Phase >= 0 && Phase <= ARRAY_SIZE(mStandbyButtonPhaseString)) {
> 
> +  if (Phase >= 0 && Phase < ARRAY_SIZE(mStandbyButtonPhaseString)) {
> 
>      return mStandbyButtonPhaseString[Phase];
> 
>    } else {
> 
>      AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);
> 
> @@ -483,7 +483,7 @@ IoTrapTypeToString (
>    IN EFI_SMM_IO_TRAP_DISPATCH_TYPE  Type
> 
>    )
> 
>  {
> 
> -  if (Type >= 0 && Type <= ARRAY_SIZE(mIoTrapTypeString)) {
> 
> +  if (Type >= 0 && Type < ARRAY_SIZE(mIoTrapTypeString)) {
> 
>      return mIoTrapTypeString[Type];
> 
>    } else {
> 
>      AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);
> 
> @@ -508,7 +508,7 @@ UsbTypeToString (
>    IN EFI_USB_SMI_TYPE          Type
> 
>    )
> 
>  {
> 
> -  if (Type >= 0 && Type <= ARRAY_SIZE(mUsbTypeString)) {
> 
> +  if (Type >= 0 && Type < ARRAY_SIZE(mUsbTypeString)) {
> 
>      return mUsbTypeString[Type];
> 
>    } else {
> 
>      AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);
> 
> --
> 2.25.1.windows.1


      reply	other threads:[~2020-04-03  4:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03  4:24 [PATCH v2] MdeModulePkg/SmiHandlerProfileInfo: Overflowed Array Index Guomin Jiang
2020-04-03  4:32 ` Wang, Jian J [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=D827630B58408649ACB04F44C510003625A4296C@SHSMSX107.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