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 <krzysztof.koch@arm.com>
This commit is contained in:
Krzysztof Koch 2020-01-20 19:13:44 +08:00 committed by mergify[bot]
parent 54d33a5314
commit a4826c8664
1 changed files with 14 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/** @file /** @file
SLIT table parser 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 SPDX-License-Identifier: BSD-2-Clause-Patent
@par Reference(s): @par Reference(s):
@ -75,9 +75,21 @@ ParseAcpiSlit (
AcpiTableLength, AcpiTableLength,
PARSER_PARAMS (SlitParser) 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; LocalityCount = *SlitSystemLocalityCount;
// We only print the Localities if the count is less than 16 // We only print the Localities if the count is less than 16
// If the locality count is more than 16 then refer to the // If the locality count is more than 16 then refer to the
// raw data dump. // raw data dump.