]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
ShellPkg: acpiview: MADT: Validate global pointers before use
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / AcpiParser.c
index a569c3c55406ab58536834e56ce9701f7edeffee..84c5f0468da55477acc96dfd0f949a5908d0f7a5 100644 (file)
@@ -405,6 +405,39 @@ Dump8Chars (
     );\r
 }\r
 \r
+/**\r
+  This function traces 12 characters which can be optionally\r
+  formated using the format string if specified.\r
+\r
+  If no format string is specified the Format must be NULL.\r
+\r
+  @param [in] Format  Optional format string for tracing the data.\r
+  @param [in] Ptr     Pointer to the start of the buffer.\r
+**/\r
+VOID\r
+EFIAPI\r
+Dump12Chars (\r
+  IN CONST CHAR16* Format OPTIONAL,\r
+  IN       UINT8*  Ptr\r
+  )\r
+{\r
+  Print (\r
+    (Format != NULL) ? Format : L"%c%c%c%c%c%c%c%c%c%c%c%c",\r
+    Ptr[0],\r
+    Ptr[1],\r
+    Ptr[2],\r
+    Ptr[3],\r
+    Ptr[4],\r
+    Ptr[5],\r
+    Ptr[6],\r
+    Ptr[7],\r
+    Ptr[8],\r
+    Ptr[9],\r
+    Ptr[10],\r
+    Ptr[11]\r
+    );\r
+}\r
+\r
 /**\r
   This function indents and prints the ACPI table Field Name.\r
 \r
@@ -510,8 +543,15 @@ ParseAcpi (
 \r
   for (Index = 0; Index < ParserItems; Index++) {\r
     if ((Offset + Parser[Index].Length) > Length) {\r
+\r
+      // For fields outside the buffer length provided, reset any pointers\r
+      // which were supposed to be updated by this function call\r
+      if (Parser[Index].ItemPtr != NULL) {\r
+        *Parser[Index].ItemPtr = NULL;\r
+      }\r
+\r
       // We don't parse past the end of the max length specified\r
-      break;\r
+      continue;\r
     }\r
 \r
     if (GetConsistencyChecking () &&\r