linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: "Miguel García" <miguelgarciaroman8@gmail.com>,
	platform-driver-x86@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, yu.c.chen@intel.com,
	hansg@kernel.org, ilpo.jarvinen@linux.intel.com,
	luzmaximilian@gmail.com, skhan@linuxfoundation.org
Subject: Re: [PATCH] platform/x86: surfacepro3_button: replace deprecated strcpy() with strscpy()
Date: Mon, 28 Jul 2025 07:30:15 +0200	[thread overview]
Message-ID: <b925480c-231b-44e5-bf1c-1f18f8abe42d@kernel.org> (raw)
In-Reply-To: <20250724074539.37650-1-miguelgarciaroman8@gmail.com>

On 24/07/2025 09:45, Miguel García wrote:
> strcpy() is deprecated for NUL-terminated strings. Replace it with
> strscpy() to guarantee NUL-termination. 'name' is a fixed-size local
> buffer.
> 
> Signed-off-by: Miguel García <miguelgarciaroman8@gmail.com>
> ---
>  drivers/platform/surface/surfacepro3_button.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/surface/surfacepro3_button.c b/drivers/platform/surface/surfacepro3_button.c
> index 2755601f979c..9616548283a1 100644
> --- a/drivers/platform/surface/surfacepro3_button.c
> +++ b/drivers/platform/surface/surfacepro3_button.c
> @@ -211,7 +211,7 @@ static int surface_button_add(struct acpi_device *device)
>  	}
>  
>  	name = acpi_device_name(device);
> -	strcpy(name, SURFACE_BUTTON_DEVICE_NAME);
> +	strscpy(name, SURFACE_BUTTON_DEVICE_NAME, sizeof(name));


Why are you copying four/eight characters if the string is around 16?

How did you test it (and I doubt you did since you change multiple
different files from different architectures)?


Best regards,
Krzysztof

  parent reply	other threads:[~2025-07-28  5:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24  7:45 [PATCH] platform/x86: surfacepro3_button: replace deprecated strcpy() with strscpy() Miguel García
2025-07-27 20:32 ` Ilpo Järvinen
2025-07-28  1:47   ` Chen, Yu C
2025-07-28  5:30 ` Krzysztof Kozlowski [this message]
2025-07-28 19:49   ` [PATCH v2] " Miguel García
2025-07-28 20:11     ` [PATCH v3] " Miguel García
2025-08-19 10:00       ` Ilpo Järvinen
2025-07-29  7:38   ` [PATCH] " Miguel García Román

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b925480c-231b-44e5-bf1c-1f18f8abe42d@kernel.org \
    --to=krzk@kernel.org \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=miguelgarciaroman8@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=yu.c.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).