ACPICA: Switch back to using strncpy() in acpi_ut_safe_strncpy()
Subsystems (2)
PATCH 1/1 ACPICA: Switch back to using strncpy() in acpi_ut_safe_strncpy()
From: Ahmed Salem <[email protected]>
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()")
Reported-by kernel test robot <[email protected]>
Signed-off-by Ahmed Salem <[email protected]>
Signed-off-by Rafael J. Wysocki <[email protected]>
--- utnonansi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpica/utnonansi.c +1 -1
@@ -168,7 +168,7 @@ void acpi_ut_safe_strncpy(char *dest, ch {/* Always terminate destination string */ -memcpy (dest, source, dest_size); +strncpy (dest, source, dest_size); dest[dest_size -1 ] =0 ; }