Skip to content

Commit ebf2776

Browse files
X0RW3LLrafaeljw
authored andcommitted
ACPICA: Replace strncpy() with memcpy()
ACPICA commit 83019b471e1902151e67c588014ba2d09fa099a3 strncpy() is deprecated for NUL-terminated destination buffers[1]. Use memcpy() for length-bounded destinations. Link: KSPP/linux#90 [1] Link: acpica/acpica@83019b47 Signed-off-by: Ahmed Salem <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 70662db commit ebf2776

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

drivers/acpi/acpica/exconvrt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
226226
/* Copy the string to the buffer */
227227

228228
new_buf = return_desc->buffer.pointer;
229-
strncpy((char *)new_buf, (char *)obj_desc->string.pointer,
230-
obj_desc->string.length);
229+
memcpy((char *)new_buf, (char *)obj_desc->string.pointer,
230+
obj_desc->string.length);
231231
break;
232232

233233
default:

drivers/acpi/acpica/tbfind.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ acpi_tb_find_table(char *signature,
5757

5858
memset(&header, 0, sizeof(struct acpi_table_header));
5959
ACPI_COPY_NAMESEG(header.signature, signature);
60-
strncpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
61-
strncpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
60+
memcpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
61+
memcpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
6262

6363
/* Search for the table */
6464

drivers/acpi/acpica/utnonansi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void acpi_ut_safe_strncpy(char *dest, char *source, acpi_size dest_size)
168168
{
169169
/* Always terminate destination string */
170170

171-
strncpy(dest, source, dest_size);
171+
memcpy(dest, source, dest_size);
172172
dest[dest_size - 1] = 0;
173173
}
174174

include/acpi/actypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ typedef u64 acpi_integer;
522522
#define ACPI_COPY_NAMESEG(dest,src) (*ACPI_CAST_PTR (u32, (dest)) = *ACPI_CAST_PTR (u32, (src)))
523523
#else
524524
#define ACPI_COMPARE_NAMESEG(a,b) (!strncmp (ACPI_CAST_PTR (char, (a)), ACPI_CAST_PTR (char, (b)), ACPI_NAMESEG_SIZE))
525-
#define ACPI_COPY_NAMESEG(dest,src) (strncpy (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAMESEG_SIZE))
525+
#define ACPI_COPY_NAMESEG(dest,src) (memcpy (ACPI_CAST_PTR (char, (dest)), ACPI_CAST_PTR (char, (src)), ACPI_NAMESEG_SIZE))
526526
#endif
527527

528528
/* Support for the special RSDP signature (8 characters) */

0 commit comments

Comments
 (0)