Linux ACPI
 help / color / mirror / Atom feed
* [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad()
@ 2026-06-22 18:23 Rafael J. Wysocki
  2026-06-23  4:02 ` Jiri Slaby
  2026-06-23 19:28 ` Kees Cook
  0 siblings, 2 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2026-06-22 18:23 UTC (permalink / raw)
  To: Linux ACPI
  Cc: Thomas Renninger, Jiri Slaby, LKML, Saket Dumbre, Kees Cook,
	Chmielewski, Pawel

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




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

end of thread, other threads:[~2026-06-23 19:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-22 18:23 [PATCH v1] ACPICA: Unbreak tools build after switching over to strscpy_pad() Rafael J. Wysocki
2026-06-23  4:02 ` Jiri Slaby
2026-06-23 10:49   ` Rafael J. Wysocki
2026-06-23 19:28 ` Kees Cook

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