]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
ShellPkg: acpiview: Prevent infinite loop if structure length is 0
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / Parsers / Pptt / PpttParser.c
index 675ba75f02b367cd5ad9f2ac23c30ed0ab58f286..0db272c16af0ad8824c8da4c88dd409c8550112a 100644 (file)
@@ -1,7 +1,7 @@
 /** @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
@@ -425,15 +425,16 @@ ParseAcpiPptt (
       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