]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: acpiview: SRAT: Validate global pointers before use
authorKrzysztof Koch <krzysztof.koch@arm.com>
Mon, 20 Jan 2020 11:13:46 +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 SratRAType and SratRALength 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/Srat/SratParser.c

index 6fe7bf681132df08133e3e03e3ee3f020d905dd2..3613900ae322483fdd3d3383de4e22ba75b2128b 100644 (file)
@@ -399,6 +399,19 @@ ParseAcpiSrat (
       PARSER_PARAMS (SratResourceAllocationParser)\r
       );\r
 \r
+    // Check if the values used to control the parsing logic have been\r
+    // successfully read.\r
+    if ((SratRAType == NULL) ||\r
+        (SratRALength == NULL)) {\r
+      IncrementErrorCount ();\r
+      Print (\r
+        L"ERROR: Insufficient remaining table buffer length to read the " \\r
+          L"Static Resource Allocation structure header. Length = %d.\n",\r
+        AcpiTableLength - Offset\r
+        );\r
+      return;\r
+    }\r
+\r
     // Make sure the SRAT structure lies inside the table\r
     if ((Offset + *SratRALength) > AcpiTableLength) {\r
       IncrementErrorCount ();\r