diff options
author | Krzysztof Koch <krzysztof.koch@arm.com> | 2020-01-20 19:13:41 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2020-02-11 02:12:45 +0000 |
commit | 5bd326c5f3fa987dec6b6fc85254f3fc7d6eceaf (patch) | |
tree | aabea83901363f2f3abb4f1cce62a7430d9d7ac7 /ShellPkg/Library/UefiShellAcpiViewCommandLib | |
parent | 7f9e354a01d77f0b392832525ccffde95ce1e95b (diff) | |
download | edk2-5bd326c5f3fa987dec6b6fc85254f3fc7d6eceaf.zip edk2-5bd326c5f3fa987dec6b6fc85254f3fc7d6eceaf.tar.gz edk2-5bd326c5f3fa987dec6b6fc85254f3fc7d6eceaf.tar.bz2 |
ShellPkg: acpiview: Set ItemPtr to NULL for unprocessed table fields
For fields outside the buffer length provided, reset any pointers,
which were supposed to be updated by a ParseAcpi() function call to
NULL. This way one can easily validate if a pointer was successfully
updated.
The ParseAcpi() function parses the given ACPI table buffer by a
number of bytes which is a minimum of the buffer length and the length
described by ACPI_PARSER array. If the buffer length is shorter than
the array describing how to process the ACPI structure, then it is
possible that the ItemPtr inside ACPI_PARSER may not get updated or
initialized. This can lead to an error if the value pointed to by
ItemPtr is later used to control the parsing logic.
A typical example would be a 'number of elements' field in an ACPI
structure header which defines how many substructures of a given type
are present in the structure body. If the 'number of elements' field
is not parsed, we will have a dangling pointer which could cause a
problem later.
Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
Diffstat (limited to 'ShellPkg/Library/UefiShellAcpiViewCommandLib')
-rw-r--r-- | ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 2b2ecb9..84c5f04 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -543,8 +543,15 @@ ParseAcpi ( for (Index = 0; Index < ParserItems; Index++) {
if ((Offset + Parser[Index].Length) > Length) {
+
+ // For fields outside the buffer length provided, reset any pointers
+ // which were supposed to be updated by this function call
+ if (Parser[Index].ItemPtr != NULL) {
+ *Parser[Index].ItemPtr = NULL;
+ }
+
// We don't parse past the end of the max length specified
- break;
+ continue;
}
if (GetConsistencyChecking () &&
|