Linux ACPI
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: Thomas Renninger <trenn@suse.com>,
	Jiri Slaby <jirislaby@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Saket Dumbre <saket.dumbre@intel.com>,
	Kees Cook <kees@kernel.org>,
	"Chmielewski, Pawel" <pawel.chmielewski@intel.com>
Subject: [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad()
Date: Mon, 22 Jun 2026 20:23:09 +0200	[thread overview]
Message-ID: <12923581.O9o76ZdvQC@rafael.j.wysocki> (raw)

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Commit 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in
acpi_ut_safe_strncpy()") switched over the ACPICA code in the kernel to
using strscpy_pad() instead of a combination of strncpy() and manual
NUL-termination of the destination string, but it overlooked the fact
that tools also use the code in question and strscpy_pad() is not
defined in those builds.

Address that by using the original ACPICA code in non-kernel builds.

Fixes: 97f7d3f9c9ac ("ACPICA: Replace strncpy() with strscpy_pad() in acpi_ut_safe_strncpy()")
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Closes: https://lore.kernel.org/all/79e9e913-0fb1-4110-804b-c3b5d0edafe4@kernel
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpica/utnonansi.c |   10 ++++++++++
 1 file changed, 9 insertions(+)

--- a/drivers/acpi/acpica/utnonansi.c
+++ b/drivers/acpi/acpica/utnonansi.c
@@ -168,7 +168,17 @@ void acpi_ut_safe_strncpy(char *dest, ch
 {
 	/* Always terminate destination string */
 
+#ifdef __KERNEL__
 	strscpy_pad(dest, source, dest_size);
+#else
+	/*
+	 * strscpy_pad() is not defined in ACPICA tools builds, so use strncpy()
+	 * and directly NUL-terminate the destination string in that case.
+	 */
+	strncpy(dest, source, dest_size);
+	dest[dest_size - 1] = 0;
+#endif
 }
 
 #endif




             reply	other threads:[~2026-06-22 18:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 18:23 Rafael J. Wysocki [this message]
2026-06-23  4:02 ` [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad() Jiri Slaby
2026-06-23 10:49   ` Rafael J. Wysocki
2026-06-23 19:28 ` Kees Cook

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=12923581.O9o76ZdvQC@rafael.j.wysocki \
    --to=rafael@kernel.org \
    --cc=jirislaby@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pawel.chmielewski@intel.com \
    --cc=saket.dumbre@intel.com \
    --cc=trenn@suse.com \
    /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