public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] acpi: convert strncpy into strscpy
@ 2025-05-07 15:20 goralbaris
  2025-05-07 15:25 ` Rafael J. Wysocki
  2025-05-19  5:18 ` kernel test robot
  0 siblings, 2 replies; 7+ messages in thread
From: goralbaris @ 2025-05-07 15:20 UTC (permalink / raw)
  To: robert.moore, rafael.j.wysocki, lenb
  Cc: acpica-devel, linux-acpi, skhan, goralbaris

The strncpy() function is actively dangerous to use since it may not
NULL-terminate the destination string, resulting in potential memory.
Link: https://github.com/KSPP/linux/issues/90

Signed-off-by: goralbaris <goralbaris@gmail.com>
---
 drivers/acpi/acpica/tbfind.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index 1c1b2e284bd9..5536d1755188 100644
--- a/drivers/acpi/acpica/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -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);
+	strscpy(header.oem_id, oem_id, ACPI_OEM_ID_SIZE);
+	strscpy(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE);
 
 	/* Search for the table */
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-05-21 15:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 15:20 [PATCH] acpi: convert strncpy into strscpy goralbaris
2025-05-07 15:25 ` Rafael J. Wysocki
2025-05-19  5:18 ` kernel test robot
2025-05-20 16:35   ` [PATCH acpi] Replace strncpy with strscpy Baris Can Goral
2025-05-20 16:48     ` [PATCH v2] acpi: convert strncpy into strscpy Baris Can Goral
2025-05-21  7:43     ` [PATCH acpi] Replace strncpy with strscpy Mateusz Guzik
2025-05-21 15:58       ` Baris Can Goral

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox