ShellPkg: acpiview: IORT: Validate global pointers before use
Check if global (in the scope of the IORT parser) pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
This commit is contained in:
committed by
mergify[bot]
parent
84a534b406
commit
ea26838a52
@ -322,6 +322,20 @@ DumpIortNodeSmmuV1V2 (
|
|||||||
PARSER_PARAMS (IortNodeSmmuV1V2Parser)
|
PARSER_PARAMS (IortNodeSmmuV1V2Parser)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check if the values used to control the parsing logic have been
|
||||||
|
// successfully read.
|
||||||
|
if ((InterruptContextCount == NULL) ||
|
||||||
|
(InterruptContextOffset == NULL) ||
|
||||||
|
(PmuInterruptCount == NULL) ||
|
||||||
|
(PmuInterruptOffset == NULL)) {
|
||||||
|
IncrementErrorCount ();
|
||||||
|
Print (
|
||||||
|
L"ERROR: Insufficient SMMUv1/2 node length. Length = %d\n",
|
||||||
|
Length
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Offset = *InterruptContextOffset;
|
Offset = *InterruptContextOffset;
|
||||||
Index = 0;
|
Index = 0;
|
||||||
|
|
||||||
@ -433,6 +447,17 @@ DumpIortNodeIts (
|
|||||||
PARSER_PARAMS (IortNodeItsParser)
|
PARSER_PARAMS (IortNodeItsParser)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check if the values used to control the parsing logic have been
|
||||||
|
// successfully read.
|
||||||
|
if (ItsCount == NULL) {
|
||||||
|
IncrementErrorCount ();
|
||||||
|
Print (
|
||||||
|
L"ERROR: Insufficient ITS group length. Length = %d.\n",
|
||||||
|
Length
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Index = 0;
|
Index = 0;
|
||||||
|
|
||||||
while ((Index < *ItsCount) &&
|
while ((Index < *ItsCount) &&
|
||||||
@ -617,6 +642,18 @@ ParseAcpiIort (
|
|||||||
PARSER_PARAMS (IortParser)
|
PARSER_PARAMS (IortParser)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check if the values used to control the parsing logic have been
|
||||||
|
// successfully read.
|
||||||
|
if ((IortNodeCount == NULL) ||
|
||||||
|
(IortNodeOffset == NULL)) {
|
||||||
|
IncrementErrorCount ();
|
||||||
|
Print (
|
||||||
|
L"ERROR: Insufficient table length. AcpiTableLength = %d.\n",
|
||||||
|
AcpiTableLength
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Offset = *IortNodeOffset;
|
Offset = *IortNodeOffset;
|
||||||
NodePtr = Ptr + Offset;
|
NodePtr = Ptr + Offset;
|
||||||
Index = 0;
|
Index = 0;
|
||||||
@ -635,6 +672,21 @@ ParseAcpiIort (
|
|||||||
PARSER_PARAMS (IortNodeHeaderParser)
|
PARSER_PARAMS (IortNodeHeaderParser)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check if the values used to control the parsing logic have been
|
||||||
|
// successfully read.
|
||||||
|
if ((IortNodeType == NULL) ||
|
||||||
|
(IortNodeLength == NULL) ||
|
||||||
|
(IortIdMappingCount == NULL) ||
|
||||||
|
(IortIdMappingOffset == NULL)) {
|
||||||
|
IncrementErrorCount ();
|
||||||
|
Print (
|
||||||
|
L"ERROR: Insufficient remaining table buffer length to read the " \
|
||||||
|
L"IORT node header. Length = %d.\n",
|
||||||
|
AcpiTableLength - Offset
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the IORT Node is inside the table
|
// Make sure the IORT Node is inside the table
|
||||||
if ((Offset + (*IortNodeLength)) > AcpiTableLength) {
|
if ((Offset + (*IortNodeLength)) > AcpiTableLength) {
|
||||||
IncrementErrorCount ();
|
IncrementErrorCount ();
|
||||||
|
Reference in New Issue
Block a user