From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) 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==; 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,184,1488873600"; d="scan'208";a="247032323" 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 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Hao A Wu 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: [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:22:14 -0000 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 --- 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. -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 == NULL || WantSelectItem >= BootMenuData->ItemCount) { return EFI_INVALID_PARAMETER; } + ASSERT (BootMenuData->ItemCount != 0); SavedAttribute = gST->ConOut->Mode->Attribute; RePaintItems = FALSE; StartCol = BootMenuData->MenuScreen.StartCol; -- 2.9.0.windows.1