/** @file\r
DBG2 table parser\r
\r
- Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r
+ Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
@par Reference(s):\r
return;\r
}\r
\r
- // Make sure the Debug Device Information structure lies inside the table.\r
- if ((Offset + *DbgDevInfoLen) > AcpiTableLength) {\r
+ // Validate Debug Device Information Structure length\r
+ if ((*DbgDevInfoLen == 0) ||\r
+ ((Offset + (*DbgDevInfoLen)) > AcpiTableLength)) {\r
IncrementErrorCount ();\r
Print (\r
- L"ERROR: Invalid Debug Device Information structure length. " \\r
- L"DbgDevInfoLen = %d. RemainingTableBufferLength = %d. " \\r
- L"DBG2 parsing aborted.\n",\r
+ L"ERROR: Invalid Debug Device Information Structure length. " \\r
+ L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",\r
*DbgDevInfoLen,\r
- AcpiTableLength - Offset\r
+ Offset,\r
+ AcpiTableLength\r
);\r
return;\r
}\r
/** @file\r
GTDT table parser\r
\r
- Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r
+ Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
@par Reference(s):\r
return;\r
}\r
\r
- // Make sure the Platform Timer is inside the table.\r
- if ((Offset + *PlatformTimerLength) > AcpiTableLength) {\r
+ // Validate Platform Timer Structure length\r
+ if ((*PlatformTimerLength == 0) ||\r
+ ((Offset + (*PlatformTimerLength)) > AcpiTableLength)) {\r
IncrementErrorCount ();\r
Print (\r
L"ERROR: Invalid Platform Timer Structure length. " \\r
- L"PlatformTimerLength = %d. RemainingTableBufferLength = %d. " \\r
- L"GTDT parsing aborted.\n",\r
+ L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",\r
*PlatformTimerLength,\r
- AcpiTableLength - Offset\r
+ Offset,\r
+ AcpiTableLength\r
);\r
return;\r
}\r
/** @file\r
IORT table parser\r
\r
- Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r
+ Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
@par Reference(s):\r
return;\r
}\r
\r
- // Make sure the IORT Node is inside the table\r
- if ((Offset + (*IortNodeLength)) > AcpiTableLength) {\r
+ // Validate IORT Node length\r
+ if ((*IortNodeLength == 0) ||\r
+ ((Offset + (*IortNodeLength)) > AcpiTableLength)) {\r
IncrementErrorCount ();\r
Print (\r
- L"ERROR: Invalid IORT node length. IortNodeLength = %d. " \\r
- L"RemainingTableBufferLength = %d. IORT parsing aborted.\n",\r
+ L"ERROR: Invalid IORT Node length. " \\r
+ L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",\r
*IortNodeLength,\r
- AcpiTableLength - Offset\r
+ Offset,\r
+ AcpiTableLength\r
);\r
return;\r
}\r
/** @file\r
MADT table parser\r
\r
- Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r
+ Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
@par Reference(s):\r
return;\r
}\r
\r
- // Make sure forward progress is made.\r
- if (*MadtInterruptControllerLength < 2) {\r
+ // Validate Interrupt Controller Structure length\r
+ if ((*MadtInterruptControllerLength == 0) ||\r
+ ((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength)) {\r
IncrementErrorCount ();\r
Print (\r
- L"ERROR: Structure length is too small: " \\r
- L"MadtInterruptControllerLength = %d. " \\r
- L"MadtInterruptControllerType = %d. MADT parsing aborted.\n",\r
+ L"ERROR: Invalid Interrupt Controller Structure length. " \\r
+ L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",\r
*MadtInterruptControllerLength,\r
- *MadtInterruptControllerType\r
- );\r
- return;\r
- }\r
-\r
- // Make sure the MADT structure lies inside the table\r
- if ((Offset + *MadtInterruptControllerLength) > AcpiTableLength) {\r
- IncrementErrorCount ();\r
- Print (\r
- L"ERROR: Invalid MADT structure length. " \\r
- L"MadtInterruptControllerLength = %d. " \\r
- L"RemainingTableBufferLength = %d. MADT parsing aborted.\n",\r
- *MadtInterruptControllerLength,\r
- AcpiTableLength - Offset\r
+ Offset,\r
+ AcpiTableLength\r
);\r
return;\r
}\r
/** @file\r
PPTT table parser\r
\r
- Copyright (c) 2019, ARM Limited. All rights reserved.\r
+ Copyright (c) 2019 - 2020, ARM Limited. All rights reserved.\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
@par Reference(s):\r
return;\r
}\r
\r
- // Make sure the PPTT structure lies inside the table\r
- if ((Offset + *ProcessorTopologyStructureLength) > AcpiTableLength) {\r
+ // Validate Processor Topology Structure length\r
+ if ((*ProcessorTopologyStructureLength == 0) ||\r
+ ((Offset + (*ProcessorTopologyStructureLength)) > AcpiTableLength)) {\r
IncrementErrorCount ();\r
Print (\r
- L"ERROR: Invalid PPTT structure length. " \\r
- L"ProcessorTopologyStructureLength = %d. " \\r
- L"RemainingTableBufferLength = %d. PPTT parsing aborted.\n",\r
+ L"ERROR: Invalid Processor Topology Structure length. " \\r
+ L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",\r
*ProcessorTopologyStructureLength,\r
- AcpiTableLength - Offset\r
+ Offset,\r
+ AcpiTableLength\r
);\r
return;\r
}\r
/** @file\r
SRAT table parser\r
\r
- Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r
+ Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
@par Reference(s):\r
return;\r
}\r
\r
- // Make sure the SRAT structure lies inside the table\r
- if ((Offset + *SratRALength) > AcpiTableLength) {\r
+ // Validate Static Resource Allocation Structure length\r
+ if ((*SratRALength == 0) ||\r
+ ((Offset + (*SratRALength)) > AcpiTableLength)) {\r
IncrementErrorCount ();\r
Print (\r
- L"ERROR: Invalid SRAT structure length. SratRALength = %d. " \\r
- L"RemainingTableBufferLength = %d. SRAT parsing aborted.\n",\r
+ L"ERROR: Invalid Static Resource Allocation Structure length. " \\r
+ L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",\r
*SratRALength,\r
- AcpiTableLength - Offset\r
+ Offset,\r
+ AcpiTableLength\r
);\r
return;\r
}\r