From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 27BF121A18AAB for ; Mon, 10 Apr 2017 19:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491877527; x=1523413527; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=UeXgEfPnSnRjB+BDl/1Xt1c5cV2Ie3VQQ+Klg0RmLSM=; b=D44+buOhpiesCCUz30AQSDmMx8esbPBpm+aHG3BBf3V+XVqfhCC3o0Br D5dLDuH+hIuTLsjp8stHYpXYa9pUPg==; Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2017 19:25:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,184,1488873600"; d="scan'208";a="75999259" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 10 Apr 2017 19:25:25 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 10 Apr 2017 19:24:22 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.178]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.193]) with mapi id 14.03.0319.002; Tue, 11 Apr 2017 10:24:19 +0800 From: "Wu, Hao A" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] MdeModulePkg/BootManagerMenu: Add assertion to indicate no DIV by 0 Thread-Index: AQHSsmp6KgrxKI02okmf0KHMHgtFR6G/cGbQ Date: Tue, 11 Apr 2017 02:24:19 +0000 Message-ID: References: <20170411022158.470716-1-ruiyu.ni@intel.com> In-Reply-To: <20170411022158.470716-1-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg/BootManagerMenu: Add assertion to indicate no DIV by 0 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2017 02:25:27 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao Wu Best Regards, Hao Wu > -----Original Message----- > From: Ni, Ruiyu > Sent: Tuesday, April 11, 2017 10:22 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A > Subject: [PATCH] MdeModulePkg/BootManagerMenu: Add assertion to indicate > no DIV by 0 >=20 > BootMenuSelectItem() contains code to DIV BootMenuData->ItemCount. > When BootMenuData->ItemCount can be 0, the DIV operation may > trigger CPU exception. > But in logic, this case won't happen. So add assertion to indicate > it. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ruiyu Ni > Cc: Hao A Wu > --- > MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c | 3 > ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git > a/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c > b/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c > index 6d493e1..a25f2ca 100644 > --- a/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c > +++ > b/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c > @@ -1,7 +1,7 @@ > /** @file > The application to show the Boot Manager Menu. >=20 > -Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved.
> +Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > @@ -374,6 +374,7 @@ BootMenuSelectItem ( > if (BootMenuData =3D=3D NULL || WantSelectItem >=3D BootMenuData->Item= Count) > { > return EFI_INVALID_PARAMETER; > } > + ASSERT (BootMenuData->ItemCount !=3D 0); > SavedAttribute =3D gST->ConOut->Mode->Attribute; > RePaintItems =3D FALSE; > StartCol =3D BootMenuData->MenuScreen.StartCol; > -- > 2.9.0.windows.1