]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
ShellPkg: acpiview: Prevent infinite loop if structure length is 0
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / Parsers / Gtdt / GtdtParser.c
index 699a55b549ec3fa61bbd156898821055dc019199..bdd30ff45c61142c071ead63a27babab8998721b 100644 (file)
@@ -1,7 +1,7 @@
 /** @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
@@ -327,15 +327,16 @@ ParseAcpiGtdt (
       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