From nobody Sat Nov 2 10:19:29 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 149187736598589.09397579191284; Mon, 10 Apr 2017 19:22:45 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EB79321A04802; Mon, 10 Apr 2017 19:22:14 -0700 (PDT) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 DD32F21A18AAB for ; Mon, 10 Apr 2017 19:22:13 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2017 19:22:13 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga004.fm.intel.com with ESMTP; 10 Apr 2017 19:22:12 -0700 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1491877333; x=1523413333; h=from:to:cc:subject:date:message-id; bh=zasVFJTSoqpcA8LuXbaZ2GV74/Kmi50gCfllxSIt5xM=; b=UE2ta0IoHO/rM7zGyhbY8Xhma3pvTWeooylMNh5gKYieCfK0JWkNQ9Ad XLqZt+qmcVbQRBTsYjoHWRMMXqHRdg==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,184,1488873600"; d="scan'208";a="247032323" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 11 Apr 2017 10:21:58 +0800 Message-Id: <20170411022158.470716-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [edk2] [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: , Cc: Hao A Wu MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni Cc: Hao A Wu Reviewed-by: Hao Wu --- MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 BSD = License which accompanies this distribution. The full text of the license may be = found at @@ -374,6 +374,7 @@ BootMenuSelectItem ( if (BootMenuData =3D=3D NULL || WantSelectItem >=3D BootMenuData->ItemCo= unt) { return EFI_INVALID_PARAMETER; } + ASSERT (BootMenuData->ItemCount !=3D 0); SavedAttribute =3D gST->ConOut->Mode->Attribute; RePaintItems =3D FALSE; StartCol =3D BootMenuData->MenuScreen.StartCol; --=20 2.9.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel