From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.4844.1585887874607629708 for ; Thu, 02 Apr 2020 21:24:34 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: guomin.jiang@intel.com) IronPort-SDR: OZ4N0Px16L1tt9EIsY5/dBpIorf7cBCdjz7cEKVKQmaVTPbF9ObsgmzC2Qup/PRnD6fWSe4sZY w69zLG39Bk8A== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2020 21:24:34 -0700 IronPort-SDR: rxMJhdqvg2DxS+AEUWChzU8Sf+f7v2JEvmxCvltwQTxwP6Aw1RKU8Pn8WBGkbgRblA8s10Dhgo 0hYXRLATMMbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,338,1580803200"; d="scan'208";a="423397162" Received: from unknown (HELO guominji-MOBL.ccr.corp.intel.com) ([10.239.158.25]) by orsmga005.jf.intel.com with ESMTP; 02 Apr 2020 21:24:32 -0700 From: "Guomin Jiang" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Eric Dong , Ray Ni Subject: [PATCH v2] MdeModulePkg/SmiHandlerProfileInfo: Overflowed Array Index Date: Fri, 3 Apr 2020 12:24:31 +0800 Message-Id: <20200403042431.1299-1-guomin.jiang@intel.com> X-Mailer: git-send-email 2.25.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2272 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2287 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2288 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2289 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2290 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 Cc: Hao A Wu Cc: Eric Dong Cc: Ray Ni Signed-off-by: Guomin Jiang --- .../SmiHandlerProfileInfo/SmiHandlerProfileInfo.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfi= leInfo.c b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfile= Info.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=0D )=0D {=0D - if (Type >=3D 0 && Type <=3D ARRAY_SIZE(mSxTypeString)) {=0D + if (Type >=3D 0 && Type < ARRAY_SIZE(mSxTypeString)) {=0D return mSxTypeString[Type];=0D } else {=0D AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);=0D @@ -407,7 +407,7 @@ SxPhaseToString ( IN EFI_SLEEP_PHASE Phase=0D )=0D {=0D - if (Phase >=3D 0 && Phase <=3D ARRAY_SIZE(mSxPhaseString)) {=0D + if (Phase >=3D 0 && Phase < ARRAY_SIZE(mSxPhaseString)) {=0D return mSxPhaseString[Phase];=0D } else {=0D AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);=0D @@ -432,7 +432,7 @@ PowerButtonPhaseToString ( IN EFI_POWER_BUTTON_PHASE Phase=0D )=0D {=0D - if (Phase >=3D 0 && Phase <=3D ARRAY_SIZE(mPowerButtonPhaseString)) {=0D + if (Phase >=3D 0 && Phase < ARRAY_SIZE(mPowerButtonPhaseString)) {=0D return mPowerButtonPhaseString[Phase];=0D } else {=0D AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);=0D @@ -457,7 +457,7 @@ StandbyButtonPhaseToString ( IN EFI_STANDBY_BUTTON_PHASE Phase=0D )=0D {=0D - if (Phase >=3D 0 && Phase <=3D ARRAY_SIZE(mStandbyButtonPhaseString)) {= =0D + if (Phase >=3D 0 && Phase < ARRAY_SIZE(mStandbyButtonPhaseString)) {=0D return mStandbyButtonPhaseString[Phase];=0D } else {=0D AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase);=0D @@ -483,7 +483,7 @@ IoTrapTypeToString ( IN EFI_SMM_IO_TRAP_DISPATCH_TYPE Type=0D )=0D {=0D - if (Type >=3D 0 && Type <=3D ARRAY_SIZE(mIoTrapTypeString)) {=0D + if (Type >=3D 0 && Type < ARRAY_SIZE(mIoTrapTypeString)) {=0D return mIoTrapTypeString[Type];=0D } else {=0D AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);=0D @@ -508,7 +508,7 @@ UsbTypeToString ( IN EFI_USB_SMI_TYPE Type=0D )=0D {=0D - if (Type >=3D 0 && Type <=3D ARRAY_SIZE(mUsbTypeString)) {=0D + if (Type >=3D 0 && Type < ARRAY_SIZE(mUsbTypeString)) {=0D return mUsbTypeString[Type];=0D } else {=0D AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type);=0D --=20 2.25.1.windows.1