ShellPkg: acpiview: SRAT: Validate global pointers before use

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>
This commit is contained in:
Krzysztof Koch 2020-01-20 19:13:46 +08:00 committed by mergify[bot]
parent eb9db72ca8
commit ce7b77a71b
1 changed files with 13 additions and 0 deletions

View File

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