summaryrefslogtreecommitdiffstats
path: root/ShellPkg
diff options
context:
space:
mode:
authorKrzysztof Koch <krzysztof.koch@arm.com>2020-01-20 19:13:47 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-02-11 02:12:45 +0000
commitc4a53853c10bee5be821cf0df2d1514d0cff7dc9 (patch)
treed20bfdafb44c01d1655e405f82d3f4bbfb9191eb /ShellPkg
parentce7b77a71b467daa6ff68f4f3a1330dffc620322 (diff)
downloadedk2-c4a53853c10bee5be821cf0df2d1514d0cff7dc9.tar.gz
edk2-c4a53853c10bee5be821cf0df2d1514d0cff7dc9.tar.bz2
edk2-c4a53853c10bee5be821cf0df2d1514d0cff7dc9.zip
ShellPkg: acpiview: MADT: Validate global pointers before use
Check if the MadtInterruptControllerType and MadtInterruptControllerLength 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/Madt/MadtParser.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
index 90bdafea19..438905cb24 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
@@ -260,6 +260,19 @@ ParseAcpiMadt (
PARSER_PARAMS (MadtInterruptControllerHeaderParser)
);
+ // Check if the values used to control the parsing logic have been
+ // successfully read.
+ if ((MadtInterruptControllerType == NULL) ||
+ (MadtInterruptControllerLength == NULL)) {
+ IncrementErrorCount ();
+ Print (
+ L"ERROR: Insufficient remaining table buffer length to read the " \
+ L"Interrupt Controller Structure header. Length = %d.\n",
+ AcpiTableLength - Offset
+ );
+ return;
+ }
+
// Make sure forward progress is made.
if (*MadtInterruptControllerLength < 2) {
IncrementErrorCount ();