diff options
author | jkim <jkim@FreeBSD.org> | 2015-04-09 21:26:23 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2015-04-09 21:26:23 +0000 |
commit | 7952f9855696db5fb0528cd82b4803bd3e752150 (patch) | |
tree | 76dc361ba38347f08358cb1656865677036bb9a7 /usr.sbin | |
parent | 7d6898c7b929f826299065640f7ca3e4b5588607 (diff) | |
download | FreeBSD-src-7952f9855696db5fb0528cd82b4803bd3e752150.zip FreeBSD-src-7952f9855696db5fb0528cd82b4803bd3e752150.tar.gz |
Do not crash when RSDT/XSDT contains an empty entry.
Reported by: Slawa Olhovchenkov <slw@zxy.spb.ru>
MFC after: 3 days
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/acpi/acpidump/acpi.c | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/usr.sbin/acpi/acpidump/acpi.c b/usr.sbin/acpi/acpidump/acpi.c index ae7ebf2..5c27f15 100644 --- a/usr.sbin/acpi/acpidump/acpi.c +++ b/usr.sbin/acpi/acpidump/acpi.c @@ -1085,17 +1085,10 @@ acpi_print_rsdt(ACPI_TABLE_HEADER *rsdp) for (i = 0; i < entries; i++) { if (i > 0) printf(", "); - switch (addr_size) { - case 4: + if (addr_size == 4) addr = le32toh(rsdt->TableOffsetEntry[i]); - break; - case 8: + else addr = le64toh(xsdt->TableOffsetEntry[i]); - break; - default: - addr = 0; - } - assert(addr != 0); printf("0x%08lx", addr); } printf(" }\n"); @@ -1342,17 +1335,12 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp) xsdt = (ACPI_TABLE_XSDT *)rsdp; entries = (rsdp->Length - sizeof(ACPI_TABLE_HEADER)) / addr_size; for (i = 0; i < entries; i++) { - switch (addr_size) { - case 4: + if (addr_size == 4) addr = le32toh(rsdt->TableOffsetEntry[i]); - break; - case 8: + else addr = le64toh(xsdt->TableOffsetEntry[i]); - break; - default: - assert((addr = 0)); - } - + if (addr == 0) + continue; sdp = (ACPI_TABLE_HEADER *)acpi_map_sdt(addr); if (acpi_checksum(sdp, sdp->Length)) { warnx("RSDT entry %d (sig %.4s) is corrupt", i, @@ -1547,16 +1535,12 @@ sdt_from_rsdt(ACPI_TABLE_HEADER *rsdp, const char *sig, ACPI_TABLE_HEADER *last) xsdt = (ACPI_TABLE_XSDT *)rsdp; entries = (rsdp->Length - sizeof(ACPI_TABLE_HEADER)) / addr_size; for (i = 0; i < entries; i++) { - switch (addr_size) { - case 4: + if (addr_size == 4) addr = le32toh(rsdt->TableOffsetEntry[i]); - break; - case 8: + else addr = le64toh(xsdt->TableOffsetEntry[i]); - break; - default: - assert((addr = 0)); - } + if (addr == 0) + continue; sdt = (ACPI_TABLE_HEADER *)acpi_map_sdt(addr); if (last != NULL) { if (sdt == last) |