From: Ahmed Salem Date: Thu, 29 May 2025 15:43:13 +0000 (+0200) Subject: ACPICA: Switch back to using strncpy() in acpi_ut_safe_strncpy() X-Git-Tag: v6.16-rc1~108^2^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d0b29661a95bbf804b6fe9bdff1d8927206c9f38;p=thirdparty%2Flinux.git ACPICA: Switch back to using strncpy() in acpi_ut_safe_strncpy() ACPICA commit b90d0d65ec97ff8279ad826f4102e0d31c5f662a I mistakenly replaced strncpy() with memcpy() in commit ebf27765421c ("ACPICA: Replace strncpy() with memcpy()"), not realizing the entire context behind *why* strncpy() was used. In this safer implementation of strncpy(), it does not make sense to use memcpy() only to null-terminate strings passed to acpi_ut_safe_strncpy() one byte early. The consequences of doing so are understandably *bad*, as was evident by the kernel test bot reporting problems [1]. Fixes: ebf27765421c ("ACPICA: Replace strncpy() with memcpy()") Link: https://lore.kernel.org/all/202505081033.50e45ff4-lkp@intel.com [1] Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202505081033.50e45ff4-lkp@intel.com Link: https://github.com/acpica/acpica/commit/b90d0d65 Signed-off-by: Ahmed Salem Signed-off-by: Rafael J. Wysocki Link: https://patch.msgid.link/12685690.O9o76ZdvQC@rjwysocki.net --- diff --git a/drivers/acpi/acpica/utnonansi.c b/drivers/acpi/acpica/utnonansi.c index 803e3e8938251..ff0802ace19b7 100644 --- a/drivers/acpi/acpica/utnonansi.c +++ b/drivers/acpi/acpica/utnonansi.c @@ -168,7 +168,7 @@ void acpi_ut_safe_strncpy(char *dest, char *source, acpi_size dest_size) { /* Always terminate destination string */ - memcpy(dest, source, dest_size); + strncpy(dest, source, dest_size); dest[dest_size - 1] = 0; }