summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg/Library
diff options
context:
space:
mode:
authorPierre Gondois <Pierre.Gondois@arm.com>2021-12-09 10:25:05 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-13 12:48:42 +0000
commitec37fd9c1fbc6c14ad3291b415ad6677a022a554 (patch)
treeb2502020426db1bb0cf0fe670af914cf6370b38a /DynamicTablesPkg/Library
parente35a746cf56420d22bcf2a838213379b9de27c7e (diff)
downloadedk2-ec37fd9c1fbc6c14ad3291b415ad6677a022a554.tar.gz
edk2-ec37fd9c1fbc6c14ad3291b415ad6677a022a554.tar.bz2
edk2-ec37fd9c1fbc6c14ad3291b415ad6677a022a554.zip
DynamicTablesPkg: Fix multiple objects parsing
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> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Diffstat (limited to 'DynamicTablesPkg/Library')
-rw-r--r--DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
index 84a35e8314..c1b21d24a4 100644
--- a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
+++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
@@ -688,6 +688,7 @@ ParseCmObjDesc (
UINT32 ObjIndex;
UINT32 ObjectCount;
INTN RemainingSize;
+ INTN Offset;
CONST CM_OBJ_PARSER_ARRAY *ParserArray;
if ((CmObjDesc == NULL) || (CmObjDesc->Data == NULL)) {
@@ -722,6 +723,7 @@ ParseCmObjDesc (
ObjectCount = CmObjDesc->Count;
RemainingSize = CmObjDesc->Size;
+ Offset = 0;
for (ObjIndex = 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 = CmObjDesc->Size - RemainingSize;
} // for
+
+ ASSERT (RemainingSize == 0);
}