summaryrefslogtreecommitdiffstats
path: root/ShellPkg
diff options
context:
space:
mode:
authorKrzysztof Koch <krzysztof.koch@arm.com>2020-01-20 19:13:46 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-02-11 02:12:45 +0000
commitce7b77a71b467daa6ff68f4f3a1330dffc620322 (patch)
tree2e06ff3f6305dd472cc858b1de6cdded002cc86c /ShellPkg
parenteb9db72ca867bbe833aaea69178b5a01b686d9bd (diff)
downloadedk2-ce7b77a71b467daa6ff68f4f3a1330dffc620322.tar.gz
edk2-ce7b77a71b467daa6ff68f4f3a1330dffc620322.tar.bz2
edk2-ce7b77a71b467daa6ff68f4f3a1330dffc620322.zip
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>
Diffstat (limited to 'ShellPkg')
-rw-r--r--ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c13
1 files changed, 13 insertions, 0 deletions
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 ();