From: Pierre Gondois <pierre.gond...@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.gond...@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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#83875): https://edk2.groups.io/g/devel/message/83875
Mute This Topic: https://groups.io/mt/87148952/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to