From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.4912.1585888377469881514 for ; Thu, 02 Apr 2020 21:32:57 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: jian.j.wang@intel.com) IronPort-SDR: gCiqfCxkpHTtZoZXS6sA55Inef4FLb+rrh9gU3hcbtCxZLeRstXgece7aqR5pmFiuye8CxZIFK cdu/X/xPrHuw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2020 21:32:56 -0700 IronPort-SDR: tofe0pTWQJ2yCedbX/YVMDdEI380IkADaFqXv9AMMtNo5wlBaZ0d3J1EVOaHZSqt63GIJ/3ZmX CTHdn4rVX2VA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,338,1580803200"; d="scan'208";a="242710230" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga008.fm.intel.com with ESMTP; 02 Apr 2020 21:32:56 -0700 Received: from fmsmsx163.amr.corp.intel.com (10.18.125.72) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Apr 2020 21:32:56 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx163.amr.corp.intel.com (10.18.125.72) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 2 Apr 2020 21:32:56 -0700 Received: from shsmsx107.ccr.corp.intel.com ([169.254.9.191]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.7]) with mapi id 14.03.0439.000; Fri, 3 Apr 2020 12:32:53 +0800 From: "Wang, Jian J" To: "Jiang, Guomin" , "devel@edk2.groups.io" CC: "Wu, Hao A" , "Dong, Eric" , "Ni, Ray" Subject: Re: [PATCH v2] MdeModulePkg/SmiHandlerProfileInfo: Overflowed Array Index Thread-Topic: [PATCH v2] MdeModulePkg/SmiHandlerProfileInfo: Overflowed Array Index Thread-Index: AQHWCW/LVevCDZTRFE+VY7uye08gOKhmzvJw Date: Fri, 3 Apr 2020 04:32:52 +0000 Message-ID: References: <20200403042431.1299-1-guomin.jiang@intel.com> In-Reply-To: <20200403042431.1299-1-guomin.jiang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: jian.j.wang@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jian J Wang Regards, Jian > -----Original Message----- > From: Jiang, Guomin > Sent: Friday, April 03, 2020 12:25 PM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A ; > Dong, Eric ; Ni, Ray > Subject: [PATCH v2] MdeModulePkg/SmiHandlerProfileInfo: Overflowed Array > Index >=20 > 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 >=20 > Index should be off-by one than size of array, so when check > array, the max index should less than size of array. >=20 > 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(-) >=20 > 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 >=20 > ) >=20 > { >=20 > - if (Type >=3D 0 && Type <=3D ARRAY_SIZE(mSxTypeString)) { >=20 > + if (Type >=3D 0 && Type < ARRAY_SIZE(mSxTypeString)) { >=20 > return mSxTypeString[Type]; >=20 > } else { >=20 > AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type); >=20 > @@ -407,7 +407,7 @@ SxPhaseToString ( > IN EFI_SLEEP_PHASE Phase >=20 > ) >=20 > { >=20 > - if (Phase >=3D 0 && Phase <=3D ARRAY_SIZE(mSxPhaseString)) { >=20 > + if (Phase >=3D 0 && Phase < ARRAY_SIZE(mSxPhaseString)) { >=20 > return mSxPhaseString[Phase]; >=20 > } else { >=20 > AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase); >=20 > @@ -432,7 +432,7 @@ PowerButtonPhaseToString ( > IN EFI_POWER_BUTTON_PHASE Phase >=20 > ) >=20 > { >=20 > - if (Phase >=3D 0 && Phase <=3D ARRAY_SIZE(mPowerButtonPhaseString)) { >=20 > + if (Phase >=3D 0 && Phase < ARRAY_SIZE(mPowerButtonPhaseString)) { >=20 > return mPowerButtonPhaseString[Phase]; >=20 > } else { >=20 > AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase); >=20 > @@ -457,7 +457,7 @@ StandbyButtonPhaseToString ( > IN EFI_STANDBY_BUTTON_PHASE Phase >=20 > ) >=20 > { >=20 > - if (Phase >=3D 0 && Phase <=3D ARRAY_SIZE(mStandbyButtonPhaseString)) = { >=20 > + if (Phase >=3D 0 && Phase < ARRAY_SIZE(mStandbyButtonPhaseString)) { >=20 > return mStandbyButtonPhaseString[Phase]; >=20 > } else { >=20 > AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Phase); >=20 > @@ -483,7 +483,7 @@ IoTrapTypeToString ( > IN EFI_SMM_IO_TRAP_DISPATCH_TYPE Type >=20 > ) >=20 > { >=20 > - if (Type >=3D 0 && Type <=3D ARRAY_SIZE(mIoTrapTypeString)) { >=20 > + if (Type >=3D 0 && Type < ARRAY_SIZE(mIoTrapTypeString)) { >=20 > return mIoTrapTypeString[Type]; >=20 > } else { >=20 > AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type); >=20 > @@ -508,7 +508,7 @@ UsbTypeToString ( > IN EFI_USB_SMI_TYPE Type >=20 > ) >=20 > { >=20 > - if (Type >=3D 0 && Type <=3D ARRAY_SIZE(mUsbTypeString)) { >=20 > + if (Type >=3D 0 && Type < ARRAY_SIZE(mUsbTypeString)) { >=20 > return mUsbTypeString[Type]; >=20 > } else { >=20 > AsciiSPrint (mNameString, sizeof(mNameString), "0x%x", Type); >=20 > -- > 2.25.1.windows.1