From: Jason Gunthorpe <jgg@nvidia.com>
To: Gal Pressman <galpress@amazon.com>
Cc: Doug Ledford <dledford@redhat.com>,
linux-rdma@vger.kernel.org, Firas JahJah <firasj@amazon.com>,
Yossi Leybovich <sleybo@amazon.com>
Subject: Re: [PATCH for-next] RDMA/efa: Use strscpy instead of strlcpy
Date: Mon, 22 Mar 2021 13:55:46 -0300 [thread overview]
Message-ID: <20210322165546.GX2356281@nvidia.com> (raw)
In-Reply-To: <fd35f82a-abd8-ff53-d8d2-0e401ec92ea0@amazon.com>
On Mon, Mar 22, 2021 at 03:11:33PM +0200, Gal Pressman wrote:
>
> On 22/03/2021 15:01, Jason Gunthorpe wrote:
> > On Tue, Mar 16, 2021 at 03:24:16PM +0200, Gal Pressman wrote:
> >> The strlcpy function doesn't limit the source length, use the preferred
> >> strscpy function instead.
> >
> > Why do we need to limit the source length here? Either this is a bug
> > because the source string is no NULL terminated or it is OK as is?
>
> It's not a bug as is, but it addresses checkpatch's warning:
> WARNING: Prefer strscpy over strlcpy - see: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Okay.. but why is it so weird:
strscpy(hinf->kernel_ver_str, utsname()->version,
min(sizeof(hinf->kernel_ver_str), sizeof(utsname()->version)));
?
utsname()->version is null terminated, yes? Why does it need to be
min'd?
Jason
next prev parent reply other threads:[~2021-03-22 16:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 13:24 [PATCH for-next] RDMA/efa: Use strscpy instead of strlcpy Gal Pressman
2021-03-22 13:01 ` Jason Gunthorpe
2021-03-22 13:11 ` Gal Pressman
2021-03-22 16:55 ` Jason Gunthorpe [this message]
2021-03-22 17:14 ` Gal Pressman
2021-03-23 0:21 ` Jason Gunthorpe
2021-03-29 7:04 ` Gal Pressman
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=20210322165546.GX2356281@nvidia.com \
--to=jgg@nvidia.com \
--cc=dledford@redhat.com \
--cc=firasj@amazon.com \
--cc=galpress@amazon.com \
--cc=linux-rdma@vger.kernel.org \
--cc=sleybo@amazon.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