[PATCH] lib: fwts_acpi_table: fix fwts_acpi_reserved_zero_array with the input string
Ivan Hu
ivan.hu at canonical.com
Tue Oct 3 08:29:23 UTC 2023
BugLink: https://bugs.launchpad.net/fwts/+bug/2038278
Got below defects for Coverity Scan whec MPAM test calling
fwts_acpi_reserved_zero_array,
CID 1521581: (STRING_NULL)
Calling "fwts_acpi_reserved_zero_array" with the input string ""MPAM"",
which is greater than or equal to 4 in length, or not null-terminated.
Fix it without function changed.
Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
---
src/lib/src/fwts_acpi_tables.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
index 377b9676..fbab323f 100644
--- a/src/lib/src/fwts_acpi_tables.c
+++ b/src/lib/src/fwts_acpi_tables.c
@@ -1485,8 +1485,8 @@ void fwts_acpi_reserved_zero_array(
char label[20];
uint8_t i;
- strncpy(label + 4, "ReservedNonZero", sizeof(label) - 4);
- strncpy(label, table, 4); /* ACPI table name is 4 char long */
+ strncpy(label, table, sizeof(label) - 1);
+ strcat(label, "ReservedNonZero");
for (i = 0; i < length; i++)
value += data[i];
--
2.34.1
More information about the fwts-devel
mailing list