Linux ACPI
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ACPI: event: replace strcpy() by strscpy()
Date: Wed, 01 May 2019 12:12:35 +0200	[thread overview]
Message-ID: <3853797.yZSUUGEqGl@kreacher> (raw)
In-Reply-To: <20190422163934.GA2636@embeddedor>

On Monday, April 22, 2019 6:39:34 PM CEST Gustavo A. R. Silva wrote:
> The strcpy() function is being deprecated. Replace it by the safer
> strscpy() and fix the following Coverity warnings:
> 
> "You might overrun the 15-character fixed-size string event->bus_id
> by copying bus_id without checking the length."
> 
> "You might overrun the 20-character fixed-size string event->device_class
> by copying device_class without checking the length."
> 
> Addresses-Coverity-ID: 139001 ("Copy into fixed size buffer")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>  drivers/acpi/event.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
> index 5a127f3f2d5c..47f21599f2ab 100644
> --- a/drivers/acpi/event.c
> +++ b/drivers/acpi/event.c
> @@ -131,8 +131,8 @@ int acpi_bus_generate_netlink_event(const char *device_class,
>  	event = nla_data(attr);
>  	memset(event, 0, sizeof(struct acpi_genl_event));
>  
> -	strcpy(event->device_class, device_class);
> -	strcpy(event->bus_id, bus_id);
> +	strscpy(event->device_class, device_class, sizeof(event->device_class));
> +	strscpy(event->bus_id, bus_id, sizeof(event->bus_id));
>  	event->type = type;
>  	event->data = data;
>  
> 

Applied, thanks!

  parent reply	other threads:[~2019-05-01 10:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-22 16:39 [PATCH] ACPI: event: replace strcpy() by strscpy() Gustavo A. R. Silva
2019-04-22 16:39 ` Gustavo A. R. Silva
2019-05-01 10:12 ` Rafael J. Wysocki [this message]
2019-05-01 10:12   ` Rafael J. Wysocki

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=3853797.yZSUUGEqGl@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=gustavo@embeddedor.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@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