linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Len Baker <len.baker@gmx.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Nikolay Kyx <knv418@gmail.com>,
	Aditya Srivastava <yashsri421@gmail.com>,
	Jiapeng Chong <jiapeng.chong@linux.alibaba.com>,
	William Durand <will+git@drnd.me>,
	Romain Perier <romain.perier@gmail.com>,
	Allen Pais <apais@linux.microsoft.com>,
	Phillip Potter <phil@philpotter.co.uk>,
	zhaoxiao <zhaoxiao@uniontech.com>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging/rtl8192e: Remove all strcpy() uses in favor of strscpy()
Date: Mon, 19 Jul 2021 08:43:45 +0300	[thread overview]
Message-ID: <20210719054345.GO1931@kadam> (raw)
In-Reply-To: <20210718090636.7905-1-len.baker@gmx.com>

On Sun, Jul 18, 2021 at 11:06:36AM +0200, Len Baker wrote:
> diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> index f89799d43b1b..5968407c646d 100644
> --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
> @@ -543,7 +543,7 @@ int rtllib_wx_get_name(struct rtllib_device *ieee,
>  			     struct iw_request_info *info,
>  			     union iwreq_data *wrqu, char *extra)
>  {
> -	strcpy(wrqu->name, "802.11");
> +	strscpy(wrqu->name, "802.11", sizeof(wrqu->name));
> 
>  	if (ieee->modulation & RTLLIB_CCK_MODULATION)
>  		strcat(wrqu->name, "b");

This patch is just about silencing inferior static analysis tools,
right?  Most checkers can figure out the size of the array and verify
that it has space for "802.11".  Probably it's only raw grep which
can't.

It doesn't make sense to me that we have strscpy() followed by strcat.
So let's fix both.

regards,
dan carpenter

  reply	other threads:[~2021-07-19  5:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-18  9:06 [PATCH] staging/rtl8192e: Remove all strcpy() uses in favor of strscpy() Len Baker
2021-07-19  5:43 ` Dan Carpenter [this message]
2021-07-23 16:30   ` Len Baker

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=20210719054345.GO1931@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=apais@linux.microsoft.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=knv418@gmail.com \
    --cc=len.baker@gmx.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=phil@philpotter.co.uk \
    --cc=romain.perier@gmail.com \
    --cc=will+git@drnd.me \
    --cc=yashsri421@gmail.com \
    --cc=zhaoxiao@uniontech.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).