mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Luke Jones" <luke@ljones.dev>
To: "Abdul Rahim" <abdul.rahim@myyahoo.com>,
	corentin.chary@gmail.com, "Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] asus-laptop: prefer strscpy() over strcpy()
Date: Thu, 10 Oct 2024 12:10:48 +1300	[thread overview]
Message-ID: <5cb4ed29-0039-432a-be2f-629aa7e1278c@app.fastmail.com> (raw)
In-Reply-To: <20241009230558.51892-1-abdul.rahim@myyahoo.com>

On Thu, 10 Oct 2024, at 12:05 PM, Abdul Rahim wrote:
> The function strcpy() is depreciated and potentially unsafe. It performs
> no bounds checking on the destination buffer. This could result in
> linear overflows beyond the end of the buffer, leading to all kinds of
> misbehaviors. The safe replacement is strscpy() [1].
>
> this fixes checkpatch warning:
>     WARNING: Prefer strscpy over strcpy
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Signed-off-by: Abdul Rahim <abdul.rahim@myyahoo.com>
> ---
>  drivers/platform/x86/asus-laptop.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-laptop.c 
> b/drivers/platform/x86/asus-laptop.c
> index 9d7e6b712abf..d460dd194f19 100644
> --- a/drivers/platform/x86/asus-laptop.c
> +++ b/drivers/platform/x86/asus-laptop.c
> @@ -1832,8 +1832,8 @@ static int asus_acpi_add(struct acpi_device 
> *device)
>  	if (!asus)
>  		return -ENOMEM;
>  	asus->handle = device->handle;
> -	strcpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
> -	strcpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
> +	strscpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME);
> +	strscpy(acpi_device_class(device), ASUS_LAPTOP_CLASS);
>  	device->driver_data = asus;
>  	asus->device = device;
> 
> -- 
> 2.43.0

Looks good, thank you for doing this.

Reviewed-by: Luke D. Jones <luke@ljones.dev>

  reply	other threads:[~2024-10-09 23:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20241009230558.51892-1-abdul.rahim.ref@myyahoo.com>
2024-10-09 23:05 ` Abdul Rahim
2024-10-09 23:10   ` Luke Jones [this message]
2024-10-10  9:40   ` Hans de Goede
2024-10-10 12:25   ` Ilpo Järvinen

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=5cb4ed29-0039-432a-be2f-629aa7e1278c@app.fastmail.com \
    --to=luke@ljones.dev \
    --cc=abdul.rahim@myyahoo.com \
    --cc=corentin.chary@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®