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

View File

@ -260,6 +260,19 @@ ParseAcpiMadt (
PARSER_PARAMS (MadtInterruptControllerHeaderParser) 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. // Make sure forward progress is made.
if (*MadtInterruptControllerLength < 2) { if (*MadtInterruptControllerLength < 2) {
IncrementErrorCount (); IncrementErrorCount ();