From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com
Subject: [PATCH v3 8/8] DynamicTablesPkg: Fix multiple objects parsing
Date: Thu, 18 Nov 2021 17:42:47 +0000 [thread overview]
Message-ID: <20211118174247.21075-9-Pierre.Gondois@arm.com> (raw)
In-Reply-To: <20211118174247.21075-1-Pierre.Gondois@arm.com>
From: Pierre Gondois <Pierre.Gondois@arm.com>
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 <Pierre.Gondois@arm.com>
---
.../ConfigurationManagerObjectParser.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
index e340ce185256..681137a0e3b2 100644
--- a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
+++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
@@ -685,7 +685,7 @@ ParseCmObjDesc (
UINTN NameSpaceId;
UINT32 ObjIndex;
UINT32 ObjectCount;
- INTN RemainingSize;
+ INTN RemainingSize, Offset;
CONST CM_OBJ_PARSER_ARRAY * ParserArray;
if ((CmObjDesc == NULL) || (CmObjDesc->Data == NULL)) {
@@ -718,6 +718,7 @@ ParseCmObjDesc (
ObjectCount = CmObjDesc->Count;
RemainingSize = CmObjDesc->Size;
+ Offset = 0;
for (ObjIndex = 0; ObjIndex < ObjectCount; ObjIndex++) {
DEBUG ((
@@ -729,11 +730,19 @@ 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 = CmObjDesc->Size - RemainingSize;
} // for
+
+ ASSERT (RemainingSize == 0);
}
--
2.17.1
prev parent reply other threads:[~2021-11-18 17:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 17:42 [PATCH v3 0/8] Create a SSDT PCIe generator PierreGondois
2021-11-18 17:42 ` [PATCH v3 1/8] DynamicTablesPkg: AML Code generation for memory ranges PierreGondois
2021-11-18 17:42 ` [PATCH v3 2/8] DynamicTablesPkg: AML Code generation to create a named Package() PierreGondois
2021-11-18 17:42 ` [PATCH v3 3/8] DynamicTablesPkg: AML Code generation to create a named ResourceTemplate() PierreGondois
2021-11-18 17:42 ` [PATCH v3 4/8] DynamicTablesPkg: AML Code generation to add _PRT entries PierreGondois
2021-11-18 17:42 ` [PATCH v3 5/8] DynamicTablesPkg: Add AmlAttachNode() PierreGondois
2021-11-18 17:42 ` [PATCH v3 6/8] DynamicTablesPkg: Add Pci related objects PierreGondois
2021-11-18 17:42 ` [PATCH v3 7/8] DynamicTablesPkg: SSDT Pci express generator PierreGondois
2021-11-18 17:42 ` PierreGondois [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211118174247.21075-9-Pierre.Gondois@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox