ShellPkg: acpiview: PPTT: Validate global pointers before use
Check if the NumberOfPrivateResources, ProcessorTopologyStructureType and ProcessorTopologyStructureLength 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
c4a53853c1
commit
84a534b406
@ -264,6 +264,17 @@ DumpProcessorHierarchyNodeStructure (
|
|||||||
PARSER_PARAMS (ProcessorHierarchyNodeStructureParser)
|
PARSER_PARAMS (ProcessorHierarchyNodeStructureParser)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check if the values used to control the parsing logic have been
|
||||||
|
// successfully read.
|
||||||
|
if (NumberOfPrivateResources == NULL) {
|
||||||
|
IncrementErrorCount ();
|
||||||
|
Print (
|
||||||
|
L"ERROR: Insufficient Processor Hierarchy Node length. Length = %d.\n",
|
||||||
|
Length
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the Private Resource array lies inside this structure
|
// Make sure the Private Resource array lies inside this structure
|
||||||
if (Offset + (*NumberOfPrivateResources * sizeof (UINT32)) > Length) {
|
if (Offset + (*NumberOfPrivateResources * sizeof (UINT32)) > Length) {
|
||||||
IncrementErrorCount ();
|
IncrementErrorCount ();
|
||||||
@ -387,6 +398,7 @@ ParseAcpiPptt (
|
|||||||
AcpiTableLength,
|
AcpiTableLength,
|
||||||
PARSER_PARAMS (PpttParser)
|
PARSER_PARAMS (PpttParser)
|
||||||
);
|
);
|
||||||
|
|
||||||
ProcessorTopologyStructurePtr = Ptr + Offset;
|
ProcessorTopologyStructurePtr = Ptr + Offset;
|
||||||
|
|
||||||
while (Offset < AcpiTableLength) {
|
while (Offset < AcpiTableLength) {
|
||||||
@ -400,6 +412,19 @@ ParseAcpiPptt (
|
|||||||
PARSER_PARAMS (ProcessorTopologyStructureHeaderParser)
|
PARSER_PARAMS (ProcessorTopologyStructureHeaderParser)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check if the values used to control the parsing logic have been
|
||||||
|
// successfully read.
|
||||||
|
if ((ProcessorTopologyStructureType == NULL) ||
|
||||||
|
(ProcessorTopologyStructureLength == NULL)) {
|
||||||
|
IncrementErrorCount ();
|
||||||
|
Print (
|
||||||
|
L"ERROR: Insufficient remaining table buffer length to read the " \
|
||||||
|
L"processor topology structure header. Length = %d.\n",
|
||||||
|
AcpiTableLength - Offset
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the PPTT structure lies inside the table
|
// Make sure the PPTT structure lies inside the table
|
||||||
if ((Offset + *ProcessorTopologyStructureLength) > AcpiTableLength) {
|
if ((Offset + *ProcessorTopologyStructureLength) > AcpiTableLength) {
|
||||||
IncrementErrorCount ();
|
IncrementErrorCount ();
|
||||||
|
Reference in New Issue
Block a user