From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] macvlan: Replace strncpy() by strscpy()
Date: Mon, 27 May 2019 16:28:05 -0500 [thread overview]
Message-ID: <e354f8c2-37d2-e76f-872f-853741f2a258@embeddedor.com> (raw)
In-Reply-To: <20190527142026.3a07831f@hermes.lan>
On 5/27/19 4:20 PM, Stephen Hemminger wrote:
> On Mon, 27 May 2019 13:38:55 -0500
> "Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:
>
>> The strncpy() function is being deprecated. Replace it by the safer
>> strscpy() and fix the following Coverity warning:
>>
>> "Calling strncpy with a maximum size argument of 16 bytes on destination
>> array ifrr.ifr_ifrn.ifrn_name of size 16 bytes might leave the destination
>> string unterminated."
>>
>> Notice that, unlike strncpy(), strscpy() always null-terminates the
>> destination string.
>>
>> Addresses-Coverity-ID: 1445537 ("Buffer not null terminated")
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> drivers/net/macvlan.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
>> index 61550122b563..0ccabde8e9c9 100644
>> --- a/drivers/net/macvlan.c
>> +++ b/drivers/net/macvlan.c
>> @@ -831,7 +831,7 @@ static int macvlan_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
>> struct ifreq ifrr;
>> int err = -EOPNOTSUPP;
>>
>> - strncpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ);
>> + strscpy(ifrr.ifr_name, real_dev->name, IFNAMSIZ);
>> ifrr.ifr_ifru = ifr->ifr_ifru;
>>
>> switch (cmd) {
>
> Why not use strlcpy like all the other places IFNAMSIZ is copied?
>
strlcpy() is also being deprecated.
--
Gustavo
next prev parent reply other threads:[~2019-05-27 21:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-27 18:38 Gustavo A. R. Silva
2019-05-27 21:20 ` Stephen Hemminger
2019-05-27 21:28 ` Gustavo A. R. Silva [this message]
2019-05-27 21:33 ` Stephen Hemminger
2019-05-29 7:00 ` David Miller
2019-05-29 7:01 ` David Miller
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=e354f8c2-37d2-e76f-872f-853741f2a258@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.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
all inboxes | Powered by JetHome®