File acpi-pmtt-fix-infinite-loops-when-length-is-incorrectly-zero.diff of Package fwts.15568

Index: fwts-20.12.00/src/acpi/pmtt/pmtt.c
===================================================================
--- fwts-20.12.00.orig/src/acpi/pmtt/pmtt.c
+++ fwts-20.12.00/src/acpi/pmtt/pmtt.c
@@ -117,6 +117,14 @@ static void pmtt_controller_test(fwts_fr
 	offset += sizeof(fwts_acpi_table_pmtt_domain) * entry->domain_count;
 	header = (fwts_acpi_table_pmtt_header *) (((char *) entry) + offset);
 	while (offset < entry->header.length) {
+
+		if (header->length == 0) {
+			fwts_failed(fw, LOG_LEVEL_CRITICAL,
+				"PMTTBadSubtableLength",
+				"PMTT Controller has a subtable with zero length");
+			break;
+		}
+
 		if (header->type == FWTS_ACPI_PMTT_TYPE_DIMM) {
 			pmtt_physical_component_test(fw, (fwts_acpi_table_pmtt_physical_component *) header, passed);
 		} else {
@@ -145,7 +153,16 @@ static void pmtt_socket_test(fwts_framew
 
 	offset = sizeof(fwts_acpi_table_pmtt_socket);
 	header = (fwts_acpi_table_pmtt_header *) (((char *) entry) + offset);
+
 	while (offset < entry->header.length) {
+
+		if (header->length == 0) {
+			fwts_failed(fw, LOG_LEVEL_CRITICAL,
+				"PMTTBadSubtableLength",
+				"PMTT Socket has a subtable with zero length");
+			break;
+		}
+
 		if (header->type == FWTS_ACPI_PMTT_TYPE_CONTROLLER) {
 			pmtt_controller_test(fw, (fwts_acpi_table_pmtt_controller *) header, passed);
 		} else {
openSUSE Build Service is sponsored by