diff mbox series

[2/2] fwts_acpi_tables: memcpy 4 char ACPI table name

Message ID 20210619172150.1294172-3-colin.king@canonical.com
State Accepted
Headers show
Series Fix build issues on s390x and ppc64el | expand

Commit Message

Colin Ian King June 19, 2021, 5:21 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Don't use strncpy, use memcpy of the raw 4 char table name.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_acpi_tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alex Hung June 19, 2021, 7:44 p.m. UTC | #1
On 2021-06-19 11:21 a.m., Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't use strncpy, use memcpy of the raw 4 char table name.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_acpi_tables.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 42285f99..b8b710bc 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -261,7 +261,7 @@ static void fwts_acpi_add_table(
>  		if (strncmp(tables[i].name, name, 4) == 0)
>  			which++;
>  		if (tables[i].data == NULL) {
> -			strncpy(tables[i].name, name, 4);
> +			memcpy(tables[i].name, name, 4);
>  			tables[i].name[4] = 0;
>  			tables[i].data = table;
>  			tables[i].addr = addr;
> 


Acked-by: Alex Hung <alex.hung@canonical.com>
Ivan Hu June 21, 2021, 4:01 a.m. UTC | #2
On 6/20/21 1:21 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Don't use strncpy, use memcpy of the raw 4 char table name.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_acpi_tables.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
> index 42285f99..b8b710bc 100644
> --- a/src/lib/src/fwts_acpi_tables.c
> +++ b/src/lib/src/fwts_acpi_tables.c
> @@ -261,7 +261,7 @@ static void fwts_acpi_add_table(
>  		if (strncmp(tables[i].name, name, 4) == 0)
>  			which++;
>  		if (tables[i].data == NULL) {
> -			strncpy(tables[i].name, name, 4);
> +			memcpy(tables[i].name, name, 4);
>  			tables[i].name[4] = 0;
>  			tables[i].data = table;
>  			tables[i].addr = addr;
> 

Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff mbox series

Patch

diff --git a/src/lib/src/fwts_acpi_tables.c b/src/lib/src/fwts_acpi_tables.c
index 42285f99..b8b710bc 100644
--- a/src/lib/src/fwts_acpi_tables.c
+++ b/src/lib/src/fwts_acpi_tables.c
@@ -261,7 +261,7 @@  static void fwts_acpi_add_table(
 		if (strncmp(tables[i].name, name, 4) == 0)
 			which++;
 		if (tables[i].data == NULL) {
-			strncpy(tables[i].name, name, 4);
+			memcpy(tables[i].name, name, 4);
 			tables[i].name[4] = 0;
 			tables[i].data = table;
 			tables[i].addr = addr;