Message ID | 20231003082923.259267-1-ivan.hu@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | lib: fwts_acpi_table: fix fwts_acpi_reserved_zero_array with the input string | expand |
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];
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@canonical.com> --- src/lib/src/fwts_acpi_tables.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)