diff mbox series

acpi: srat: fix the untrusted loop bound warning

Message ID 20240315101541.118551-1-ivan.hu@canonical.com
State Accepted
Headers show
Series acpi: srat: fix the untrusted loop bound warning | expand

Commit Message

Ivan Hu March 15, 2024, 10:15 a.m. UTC
BugLink: https://bugs.launchpad.net/fwts/+bug/2058008

coverity scan the length is untrust loop bound, which is from
tainted_data_downcast fwts_acpi_table_srat, use table->length
to avoid this warning, no function impact.

CID 323875: (#1 of 1): Untrusted loop bound (TAINTED_SCALAR)
5. tainted_data: Using tainted variable length as a loop boundary.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/acpi/srat/srat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/acpi/srat/srat.c b/src/acpi/srat/srat.c
index 9558be97..088e7542 100644
--- a/src/acpi/srat/srat.c
+++ b/src/acpi/srat/srat.c
@@ -408,7 +408,7 @@  static int srat_test1(fwts_framework *fw)
 	const fwts_acpi_table_srat *srat = (const fwts_acpi_table_srat *)table->data;
 	uint8_t *data = (uint8_t *)table->data;
 	bool passed = true;
-	ssize_t length = (ssize_t)srat->header.length;
+	ssize_t length = (ssize_t)table->length;
 
 	fwts_acpi_fixed_value(fw, LOG_LEVEL_MEDIUM, "SRAT", "Revision1", srat->reserved1, 1, &passed);