From a4826c8664f98a40fc7384107639971a93598fb3 Mon Sep 17 00:00:00 2001 From: Krzysztof Koch Date: Mon, 20 Jan 2020 19:13:44 +0800 Subject: [PATCH] ShellPkg: acpiview: SLIT: Validate global pointer before use Check if SlitSystemLocalityCount pointer has been successfully updated before it is used for further table parsing. Signed-off-by: Krzysztof Koch --- .../Parsers/Slit/SlitParser.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c index ca2808db52..17e2166a09 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c @@ -1,7 +1,7 @@ /** @file SLIT table parser - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @par Reference(s): @@ -75,9 +75,21 @@ ParseAcpiSlit ( AcpiTableLength, PARSER_PARAMS (SlitParser) ); - LocalityPtr = Ptr + Offset; + // Check if the values used to control the parsing logic have been + // successfully read. + if (SlitSystemLocalityCount == NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength = %d.\n", + AcpiTableLength + ); + return; + } + + LocalityPtr = Ptr + Offset; LocalityCount = *SlitSystemLocalityCount; + // We only print the Localities if the count is less than 16 // If the locality count is more than 16 then refer to the // raw data dump.