secure check for ssdt length

Signed-off-by: SergeySlice <sergey.slice@gmail.com>
This commit is contained in:
SergeySlice 2021-09-01 19:38:35 +03:00
parent a0c543f100
commit f7add0788f

View File

@ -913,7 +913,7 @@ void DumpChildSsdt(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CONST CHAR16 *DirNam
if (pacCount > 0 && pacCount % 3 == 0) {
pacCount /= 3;
DBG(" (Found hidden SSDT %lld pcs)\n", pacCount);
DBG(" (Found hidden SSDT %lld pcs)\n", pacCount);
while (pacCount-- > 0) {
// Skip text marker and addr type tag
@ -937,8 +937,10 @@ void DumpChildSsdt(EFI_ACPI_DESCRIPTION_HEADER *TableEntry, CONST CHAR16 *DirNam
CopyMem(&OemTableId[0], &((EFI_ACPI_DESCRIPTION_HEADER *)adr)->OemTableId, 8);
OemTableId[8] = 0;
stripTrailingSpaces(OemTableId);
DBG(" * %llu: '%s', '%s', Rev: %d, Len: %d ", adr, Signature, OemTableId,
((EFI_ACPI_DESCRIPTION_HEADER *)adr)->Revision, ((EFI_ACPI_DESCRIPTION_HEADER *)adr)->Length);
int innLen = ((EFI_ACPI_DESCRIPTION_HEADER *)adr)->Length;
if (innLen < 0 || innLen > 0x20000) break;
DBG(" * %llu: '%s', '%s', Rev: %d, Len: %d ", adr, Signature, OemTableId,
((EFI_ACPI_DESCRIPTION_HEADER *)adr)->Revision, innLen);
for (k = 0; k < 16; k++) {
DBG("%02hhX ", ((UINT8*)adr)[k]);
}