From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.6204.1573190825455333010 for ; Thu, 07 Nov 2019 21:27:05 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: shenglei.zhang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Nov 2019 21:27:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,280,1569308400"; d="scan'208";a="206368127" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 07 Nov 2019 21:27:03 -0800 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu Subject: [PATCH] MdeModulePkg/SmiHandlerProfileInfo: Update the ranges of array index Date: Fri, 8 Nov 2019 13:26:59 +0800 Message-Id: <20191108052659.44532-1-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 Take the below code as example. if (Type >= 0 && Type <= ARRAY_SIZE(mSxTypeString)) { return mSxTypeString[Type]; The variable 'Type' used as index should range from 0 ~ ARRAY_SIZE-1. So the if statement should be : if (Type >= 0 && Type < ARRAY_SIZE(mSxTypeString)) { And other cases should also follow this rule. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2272 https://bugzilla.tianocore.org/show_bug.cgi?id=2287 https://bugzilla.tianocore.org/show_bug.cgi?id=2288 https://bugzilla.tianocore.org/show_bug.cgi?id=2289 https://bugzilla.tianocore.org/show_bug.cgi?id=2290 Cc: Jian J Wang Cc: Hao A Wu Signed-off-by: Shenglei Zhang --- .../SmiHandlerProfileInfo/SmiHandlerProfileInfo.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c index 0f7163160b4e..4f195b16ceb0 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); @@ -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.18.0.windows.1