Re: [PATCH] platform/x86: replace strcpy() with strscpy()
From: Ilpo Järvinen
Date: Mon May 11 2026 - 12:55:38 EST
On Wed, 6 May 2026, Melih Emik wrote:
> Replace strcpy() with strscpy() in dell_rbu to use the preferred
>
> kernel string API for bounded copies.
>
> The destination buffer size is known at compile time
>
> (sizeof(image_type)), so this conversion is safe.
>
> No functional change intended.
>
> Signed-off-by: Melih Emik <melihemik@xxxxxxxxxxx>
> ---
> drivers/platform/x86/dell/dell_rbu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/dell/dell_rbu.c b/drivers/platform/x86/dell/dell_rbu.c
> index 3fa9de9aa47b..85eea8898fac 100644
> --- a/drivers/platform/x86/dell/dell_rbu.c
> +++ b/drivers/platform/x86/dell/dell_rbu.c
> @@ -562,9 +562,9 @@ static ssize_t image_type_write(struct file *filp, struct kobject *kobj,
> buffer[count] = '\0';
>
> if (strstr(buffer, "mono"))
> - strcpy(image_type, "mono");
> + strscpy(image_type, "mono", sizeof(image_type));
> else if (strstr(buffer, "packet"))
> - strcpy(image_type, "packet");
> + strscpy(image_type, "packet", sizeof(image_type));
As the sizeof information for image_type is available here, you should use
two input strscpy() variant instead.
--
i.