]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: acpiview: MADT: Validate global pointers before use
authorKrzysztof Koch <krzysztof.koch@arm.com>
Mon, 20 Jan 2020 11:13:47 +0000 (19:13 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 11 Feb 2020 02:12:45 +0000 (02:12 +0000)
Check if the MadtInterruptControllerType and
MadtInterruptControllerLength pointers have been successfully updated
before they are used for further table parsing.

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c

index 90bdafea1970db522e8ed96de7c6e986cdaca5ba..438905cb24f58b8b82e8fe61280e72f765d578d8 100644 (file)
@@ -260,6 +260,19 @@ ParseAcpiMadt (
       PARSER_PARAMS (MadtInterruptControllerHeaderParser)\r
       );\r
 \r
+    // Check if the values used to control the parsing logic have been\r
+    // successfully read.\r
+    if ((MadtInterruptControllerType == NULL) ||\r
+        (MadtInterruptControllerLength == NULL)) {\r
+      IncrementErrorCount ();\r
+      Print (\r
+        L"ERROR: Insufficient remaining table buffer length to read the " \\r
+          L"Interrupt Controller Structure header. Length = %d.\n",\r
+        AcpiTableLength - Offset\r
+        );\r
+      return;\r
+    }\r
+\r
     // Make sure forward progress is made.\r
     if (*MadtInterruptControllerLength < 2) {\r
       IncrementErrorCount ();\r