From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.9253.1639041925532127964 for ; Thu, 09 Dec 2021 01:25:25 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 264CA1476; Thu, 9 Dec 2021 01:25:25 -0800 (PST) Received: from e126645.nice.arm.com (unknown [10.34.129.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5238D3F73B; Thu, 9 Dec 2021 01:25:24 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [PATCH v4 8/8] DynamicTablesPkg: Fix multiple objects parsing Date: Thu, 9 Dec 2021 10:25:05 +0100 Message-Id: <20211209092505.1248326-9-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211209092505.1248326-1-Pierre.Gondois@arm.com> References: <20211209092505.1248326-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pierre Gondois When a CmObjDesc contains multiple objects, only the first one is parsed as the buffer doesn't progress. Fix this. Also check that the whole buffer has been parsed with an asset. Signed-off-by: Pierre Gondois --- Notes: v3: - New patch. [Pierre] .../ConfigurationManagerObjectParser.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/Configuration= ManagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/Co= nfigurationManagerObjectParser.c index 84a35e831471..c1b21d24a402 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManager= ObjectParser.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManager= ObjectParser.c @@ -688,6 +688,7 @@ ParseCmObjDesc ( UINT32 ObjIndex; UINT32 ObjectCount; INTN RemainingSize; + INTN Offset; CONST CM_OBJ_PARSER_ARRAY *ParserArray; =20 if ((CmObjDesc =3D=3D NULL) || (CmObjDesc->Data =3D=3D NULL)) { @@ -722,6 +723,7 @@ ParseCmObjDesc ( =20 ObjectCount =3D CmObjDesc->Count; RemainingSize =3D CmObjDesc->Size; + Offset =3D 0; =20 for (ObjIndex =3D 0; ObjIndex < ObjectCount; ObjIndex++) { DEBUG (( @@ -733,11 +735,21 @@ ParseCmObjDesc ( ObjectCount )); PrintCmObjDesc ( - CmObjDesc->Data, + (VOID *)((UINTN)CmObjDesc->Data + Offset), ParserArray->Parser, ParserArray->ItemCount, &RemainingSize, 1 ); + if ((RemainingSize > CmObjDesc->Size) || + (RemainingSize < 0)) + { + ASSERT (0); + return; + } + + Offset =3D CmObjDesc->Size - RemainingSize; } // for + + ASSERT (RemainingSize =3D=3D 0); } --=20 2.25.1