Re: [PATCH] ACPICA: Replace deprecated strncpy() with strscpy()

From: Rafael J. Wysocki
Date: Wed Mar 26 2025 - 11:06:47 EST


On Mon, Mar 17, 2025 at 7:38 AM <feng.wei8@xxxxxxxxxx> wrote:
>
> From: FengWei <feng.wei8@xxxxxxxxxx>
>
> strncpy() is deprecated for NUL-terminated destination buffers. Use
> strscpy() instead and remove the manual NUL-termination.
>
> Signed-off-by: FengWei <feng.wei8@xxxxxxxxxx>

In order to modify ACPICA code in the Linux kernel, please first
submit the change in question to the upstream ACPICA project on GitHub
as a pull request. Once that pull request has been merged, you can
send a corresponding Linux patch with a Link: tag pointing to it, but
in principle it is not necessary to do so because ACPICA changes are
automatically integrated into the Linux code base on a more-or-less
regular basis.

Thanks!

> ---
> drivers/acpi/acpica/utnonansi.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/acpica/utnonansi.c b/drivers/acpi/acpica/utnonansi.c
> index ff0802ace19b..1da9b8246011 100644
> --- a/drivers/acpi/acpica/utnonansi.c
> +++ b/drivers/acpi/acpica/utnonansi.c
> @@ -168,8 +168,7 @@ void acpi_ut_safe_strncpy(char *dest, char *source, acpi_size dest_size)
> {
> /* Always terminate destination string */
>
> - strncpy(dest, source, dest_size);
> - dest[dest_size - 1] = 0;
> + strscpy(dest, source, dest_size);
> }
>
> #endif
> --
> 2.25.1
>