]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: acpiview: SLIT: Validate global pointer before use
authorKrzysztof Koch <krzysztof.koch@arm.com>
Mon, 20 Jan 2020 11:13:44 +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 SlitSystemLocalityCount pointer has been successfully updated
before it is used for further table parsing.

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

index ca2808db526b1bbb79aeb21ccfc0ae6c79b2dfd8..17e2166a09d8615b714e0c51d4d93d293fcdf601 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   SLIT table parser\r
 \r
-  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.\r
+  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
   @par Reference(s):\r
@@ -75,9 +75,21 @@ ParseAcpiSlit (
              AcpiTableLength,\r
              PARSER_PARAMS (SlitParser)\r
              );\r
-  LocalityPtr = Ptr + Offset;\r
 \r
+  // Check if the values used to control the parsing logic have been\r
+  // successfully read.\r
+  if (SlitSystemLocalityCount == NULL) {\r
+    IncrementErrorCount ();\r
+    Print (\r
+      L"ERROR: Insufficient table length. AcpiTableLength = %d.\n",\r
+      AcpiTableLength\r
+      );\r
+    return;\r
+  }\r
+\r
+  LocalityPtr = Ptr + Offset;\r
   LocalityCount = *SlitSystemLocalityCount;\r
+\r
   // We only print the Localities if the count is less than 16\r
   // If the locality count is more than 16 then refer to the\r
   // raw data dump.\r