From: Dan Carpenter <dan.carpenter@linaro.org>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Nathan Chancellor <nathan@kernel.org>,
Justin Stitt <justinstitt@google.com>,
Arnd Bergmann <arnd@arndb.de>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Franziska Naepelt <franziska.naepelt@googlemail.com>,
Johannes Berg <johannes.berg@intel.com>,
Jeff Johnson <quic_jjohnson@quicinc.com>,
Aloka Dixit <quic_alokad@quicinc.com>,
Erick Archer <erick.archer@gmx.com>,
Yang Yingliang <yangyingliang@huawei.com>,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev
Subject: Re: [PATCH 2/3] [v2] staging: rtl8723bs: convert strncpy to strscpy
Date: Tue, 9 Apr 2024 10:10:55 +0300 [thread overview]
Message-ID: <3d8bf8b5-d8b9-4621-bd82-e51e844fd2d2@moroto.mountain> (raw)
In-Reply-To: <20240408194821.3183462-2-arnd@kernel.org>
On Mon, Apr 08, 2024 at 09:48:10PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> gcc-9 complains about a possibly unterminated string in the strncpy() destination:
>
> In function 'rtw_cfg80211_add_monitor_if',
> inlined from 'cfg80211_rtw_add_virtual_intf' at drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2209:9:
> drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:2146:2: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
> 2146 | strncpy(mon_ndev->name, name, IFNAMSIZ);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> This one is a false-positive because of the explicit termination in the following
> line, and recent versions of clang and gcc no longer warn about this.
>
> Interestingly, the other strncpy() in this file is missing a termination but
> does not produce a warning, possibly because of the type confusion and the
> cast between u8 and char.
>
> Change both strncpy() instances to strscpy(), which avoids the warning as well
> as the possibly missing termination. No additional padding is needed here.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2:
> use the two-argument version of strscpy(), which is simpler for the constant
> size destination. Add the third instance in this driver as well.
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
regards,
dan carpenter
next prev parent reply other threads:[~2024-04-09 7:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-08 19:48 [PATCH 1/3] [v2] staging: rts5208: replace weird strncpy() with memcpy() Arnd Bergmann
2024-04-08 19:48 ` [PATCH 2/3] [v2] staging: rtl8723bs: convert strncpy to strscpy Arnd Bergmann
2024-04-08 20:35 ` Justin Stitt
2024-04-09 7:10 ` Dan Carpenter [this message]
2024-04-08 19:48 ` [PATCH 3/3] [v2] staging: greybus: change strncpy() to strscpy_pad() Arnd Bergmann
2024-04-08 20:38 ` Justin Stitt
2024-04-09 7:04 ` Dan Carpenter
2024-04-08 20:28 ` [PATCH 1/3] [v2] staging: rts5208: replace weird strncpy() with memcpy() Justin Stitt
2024-04-09 5:34 ` Arnd Bergmann
2024-04-09 6:23 ` Dan Carpenter
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=3d8bf8b5-d8b9-4621-bd82-e51e844fd2d2@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=erick.archer@gmx.com \
--cc=franziska.naepelt@googlemail.com \
--cc=gregkh@linuxfoundation.org \
--cc=johannes.berg@intel.com \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=quic_alokad@quicinc.com \
--cc=quic_jjohnson@quicinc.com \
--cc=yangyingliang@huawei.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 read-only IMAP folder(s) and NNTP newsgroup(s).