]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
ShellPkg: acpiview: Prevent infinite loop if structure length is 0
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / Parsers / Iort / IortParser.c
index 9d5d937c7b2c19945ca2ad3eba644bdfc09cc3f6..9a006a01448b897865cd7cd85651c816933acf05 100644 (file)
@@ -1,7 +1,7 @@
 /** @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
@@ -687,14 +687,16 @@ ParseAcpiIort (
       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