From ce7b77a71b467daa6ff68f4f3a1330dffc620322 Mon Sep 17 00:00:00 2001 From: Krzysztof Koch Date: Mon, 20 Jan 2020 19:13:46 +0800 Subject: 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 --- .../UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c index 6fe7bf6811..3613900ae3 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c @@ -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 (); -- cgit v1.2.3