]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
ShellPkg: acpiview: SRAT: Validate global pointers before use
[mirror_edk2.git] / 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