mirror of https://github.com/acidanthera/audk.git
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>
This commit is contained in:
parent
e35a746cf5
commit
ec37fd9c1f
DynamicTablesPkg/Library/Common/TableHelperLib
|
@ -688,6 +688,7 @@ ParseCmObjDesc (
|
||||||
UINT32 ObjIndex;
|
UINT32 ObjIndex;
|
||||||
UINT32 ObjectCount;
|
UINT32 ObjectCount;
|
||||||
INTN RemainingSize;
|
INTN RemainingSize;
|
||||||
|
INTN Offset;
|
||||||
CONST CM_OBJ_PARSER_ARRAY *ParserArray;
|
CONST CM_OBJ_PARSER_ARRAY *ParserArray;
|
||||||
|
|
||||||
if ((CmObjDesc == NULL) || (CmObjDesc->Data == NULL)) {
|
if ((CmObjDesc == NULL) || (CmObjDesc->Data == NULL)) {
|
||||||
|
@ -722,6 +723,7 @@ ParseCmObjDesc (
|
||||||
|
|
||||||
ObjectCount = CmObjDesc->Count;
|
ObjectCount = CmObjDesc->Count;
|
||||||
RemainingSize = CmObjDesc->Size;
|
RemainingSize = CmObjDesc->Size;
|
||||||
|
Offset = 0;
|
||||||
|
|
||||||
for (ObjIndex = 0; ObjIndex < ObjectCount; ObjIndex++) {
|
for (ObjIndex = 0; ObjIndex < ObjectCount; ObjIndex++) {
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
|
@ -733,11 +735,21 @@ ParseCmObjDesc (
|
||||||
ObjectCount
|
ObjectCount
|
||||||
));
|
));
|
||||||
PrintCmObjDesc (
|
PrintCmObjDesc (
|
||||||
CmObjDesc->Data,
|
(VOID *)((UINTN)CmObjDesc->Data + Offset),
|
||||||
ParserArray->Parser,
|
ParserArray->Parser,
|
||||||
ParserArray->ItemCount,
|
ParserArray->ItemCount,
|
||||||
&RemainingSize,
|
&RemainingSize,
|
||||||
1
|
1
|
||||||
);
|
);
|
||||||
|
if ((RemainingSize > CmObjDesc->Size) ||
|
||||||
|
(RemainingSize < 0))
|
||||||
|
{
|
||||||
|
ASSERT (0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Offset = CmObjDesc->Size - RemainingSize;
|
||||||
} // for
|
} // for
|
||||||
|
|
||||||
|
ASSERT (RemainingSize == 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue