public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: goralbaris <goralbaris@gmail.com>
To: robert.moore@intel.com, rafael.j.wysocki@intel.com, lenb@kernel.org
Cc: acpica-devel@lists.linux.dev, linux-acpi@vger.kernel.org,
	skhan@linuxfoundation.org, goralbaris <goralbaris@gmail.com>
Subject: [PATCH] acpi: convert strncpy into strscpy
Date: Wed,  7 May 2025 18:20:45 +0300	[thread overview]
Message-ID: <20250507152045.12266-1-goralbaris@gmail.com> (raw)

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


             reply	other threads:[~2025-05-07 15:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-07 15:20 goralbaris [this message]
2025-05-07 15:25 ` [PATCH] acpi: convert strncpy into strscpy 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250507152045.12266-1-goralbaris@gmail.com \
    --to=goralbaris@gmail.com \
    --cc=acpica-devel@lists.linux.dev \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robert.moore@intel.com \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox