]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPICA: Replace strncpy() with memcpy()
authorAhmed Salem <x0rw3ll@gmail.com>
Fri, 25 Apr 2025 19:32:12 +0000 (21:32 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 12 May 2025 13:38:42 +0000 (15:38 +0200)
ACPICA commit 83019b471e1902151e67c588014ba2d09fa099a3

strncpy() is deprecated for NUL-terminated destination buffers[1].

Use memcpy() for length-bounded destinations.

Link: https://github.com/KSPP/linux/issues/90
Link: https://github.com/acpica/acpica/commit/83019b47
Signed-off-by: Ahmed Salem <x0rw3ll@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/1910878.atdPhlSkOF@rjwysocki.net
drivers/acpi/acpica/exconvrt.c
drivers/acpi/acpica/tbfind.c
drivers/acpi/acpica/utnonansi.c
include/acpi/actypes.h

index bb1be42daee107fa418f01e11df11525c83d7ece..399c005aa57baa573d247e583ec698e7783b6ef7 100644 (file)
@@ -226,8 +226,8 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
                /* Copy the string to the buffer */
 
                new_buf = return_desc->buffer.pointer;
-               strncpy((char *)new_buf, (char *)obj_desc->string.pointer,
-                       obj_desc->string.length);
+               memcpy((char *)new_buf, (char *)obj_desc->string.pointer,
+                      obj_desc->string.length);
                break;
 
        default:
index 1c1b2e284bd904cb65248542e9d69d50ffcf73e9..35f72dffc2506198dabb301cfbf3fd3d8edfb6b8 100644 (file)
@@ -57,8 +57,8 @@ acpi_tb_find_table(char *signature,
 
        memset(&header, 0, sizeof(struct acpi_table_header));
        ACPI_COPY_NAMESEG(header.signature, signature);
-       strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
-       strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
+       memcpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
+       memcpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
 
        /* Search for the table */
 
index ff0802ace19b72add24d43a2eb14b98eed920337..803e3e8938251ea4b7cb0a1401ac8b2b5fc0a144 100644 (file)
@@ -168,7 +168,7 @@ void acpi_ut_safe_strncpy(char *dest, char *source, acpi_size dest_size)
 {
        /* Always terminate destination string */
 
-       strncpy(dest, source, dest_size);
+       memcpy(dest, source, dest_size);
        dest[dest_size - 1] = 0;
 }
 
index 5b9f9a6125484f8ddc2835e77182caebbc670f85..e90ca342d7dee52f7a0f5a4c7822494a0d4affd9 100644 (file)
@@ -522,7 +522,7 @@ typedef u64 acpi_integer;
 #define ACPI_COPY_NAMESEG(dest,src)     (*ACPI_CAST_PTR (u32, (dest)) = *ACPI_CAST_PTR (u32, (src)))
 #else
 #define ACPI_COMPARE_NAMESEG(a,b)       (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAMESEG_SIZE))
-#define ACPI_COPY_NAMESEG(dest,src)     (strncpy (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAMESEG_SIZE))
+#define ACPI_COPY_NAMESEG(dest,src)     (memcpy (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAMESEG_SIZE))
 #endif
 
 /* Support for the special RSDP signature (8 characters) */