From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Abhishek Tamboli <abhishektamboli9@gmail.com>,
gregkh@linuxfoundation.org
Cc: tdavies@darkphysics.net, philipp.g.hortmann@gmail.com,
garyrookard@fastmail.org, linux-staging@lists.linux.dev,
skhan@linuxfoundation.org, rbmarliere@gmail.com,
linux-kernel-mentees@lists.linuxfoundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: rtl8192e: Replace strcpy with strscpy in rtl819x_translate_scan
Date: Tue, 20 Aug 2024 21:38:22 +0200 [thread overview]
Message-ID: <2348e646-e1da-4deb-ab55-c438a42e25b3@wanadoo.fr> (raw)
In-Reply-To: <20240820184216.45390-1-abhishektamboli9@gmail.com>
Le 20/08/2024 à 20:42, Abhishek Tamboli a écrit :
> Replace strcpy() with strscpy() in rtl819x_translate_scan()
> function to ensure buffer safety.
>
> Signed-off-by: Abhishek Tamboli <abhishektamboli9@gmail.com>
> ---
> drivers/staging/rtl8192e/rtllib_wx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c
> index fbd4ec824084..970b7fcb3f7e 100644
> --- a/drivers/staging/rtl8192e/rtllib_wx.c
> +++ b/drivers/staging/rtl8192e/rtllib_wx.c
> @@ -61,7 +61,7 @@ static inline char *rtl819x_translate_scan(struct rtllib_device *ieee,
> iwe.cmd = SIOCGIWNAME;
> for (i = 0; i < ARRAY_SIZE(rtllib_modes); i++) {
> if (network->mode & BIT(i)) {
> - strcpy(pname, rtllib_modes[i]);
> + strscpy(pname, rtllib_modes[i], sizeof(pname));
This not correct.
sizeof(pname) is 4 here, but the buffer that is really used is "char
proto_name[6];"
6 chars are needed for storing "N-24G" (see rtllib_modes), so 5 chars +
ending \0.
When you will send a v2, here are a few others things you could give a
look at:
- is 'pname' really needed or is 'proto_name' enough?
- what about the "*pname = '\0';" after the loop?
- if a "mode" matches, do we need to iterate the whole rtllib_modes
array? (have a look at wireless_mode)
CJ
> pname += strlen(rtllib_modes[i]);
> }
> }
> --
> 2.34.1
>
>
>
next prev parent reply other threads:[~2024-08-20 19:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 18:42 [PATCH] staging: rtl8192e: Replace strcpy with strscpy in rtl819x_translate_scan Abhishek Tamboli
2024-08-20 19:29 ` Dan Carpenter
2024-08-21 17:48 ` Abhishek Tamboli
2024-08-21 18:22 ` Dan Carpenter
2024-08-20 19:38 ` Christophe JAILLET [this message]
2024-08-21 18:23 ` Dan Carpenter
2024-08-24 6:35 ` Christophe JAILLET
2024-08-24 11:18 ` Dan Carpenter
2024-08-21 9:43 ` kernel test robot
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=2348e646-e1da-4deb-ab55-c438a42e25b3@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=abhishektamboli9@gmail.com \
--cc=garyrookard@fastmail.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=philipp.g.hortmann@gmail.com \
--cc=rbmarliere@gmail.com \
--cc=skhan@linuxfoundation.org \
--cc=tdavies@darkphysics.net \
/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