From nobody Tue Apr 30 01:04:50 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 149180496357012.276603151442828; Sun, 9 Apr 2017 23:16:03 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 5B059219392F4; Sun, 9 Apr 2017 23:16:02 -0700 (PDT) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 3FFC8219392F4 for ; Sun, 9 Apr 2017 23:16:01 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Apr 2017 23:16:00 -0700 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.13]) by fmsmga005.fm.intel.com with ESMTP; 09 Apr 2017 23:15:59 -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=1491804961; x=1523340961; h=from:to:cc:subject:date:message-id; bh=ad9JBvU6n1Ji/3wEPiPqLRtjhf4QtaO+9wQ8JSdFjIk=; b=uBnObX78VQGGdcOSiysilyzQBn9U0scMlXkkXnH1S8SVryI4wnkhltB5 LxktRqsw4Z9JS0N0+PXvdgjTja7h+w==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,181,1488873600"; d="scan'208";a="86797919" From: Hao Wu To: edk2-devel@lists.01.org Date: Mon, 10 Apr 2017 14:15:57 +0800 Message-Id: <20170410061557.12688-1-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 Subject: [edk2] [PATCH] MdeModulePkg/DxeCore: Add ASSERT to ensure no subtract underflow 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 Wu , Jiewen Yao 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" For function SplitRecord() in file PropertiesTable.c, there is a potential subtract underflow case for line: return TotalNewRecordCount - 1; However, such case will not happen since the logic in function SplitTable() ensure that when calling SplitRecord(), the variable 'TotalNewRecordCount' will not be zero when performing the subtraction. It will be handled in the previous if statement: if (MaxSplitRecordCount =3D=3D 0) { CopyMem (NewRecord, OldRecord, DescriptorSize); return 0; } Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: jiewen.yao@intel.com --- MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c b/MdeModulePkg/Co= re/Dxe/Misc/PropertiesTable.c index e7c4a95712..6cf5edcbe5 100644 --- a/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/PropertiesTable.c @@ -576,6 +576,11 @@ SplitRecord ( TempRecord.NumberOfPages =3D EfiSizeToPages (PhysicalEnd - PhysicalSta= rt); } while ((ImageRecord !=3D NULL) && (PhysicalStart < PhysicalEnd)); =20 + // + // The logic in function SplitTable() ensures that TotalNewRecordCount w= ill not be zero if the + // code reaches here. + // + ASSERT (TotalNewRecordCount !=3D 0); return TotalNewRecordCount - 1; } =20 --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel