* [PATCH net-next] macvlan: Replace strncpy() by strscpy()
@ 2019-05-27 18:38 Gustavo A. R. Silva
2019-05-27 21:20 ` Stephen Hemminger
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2019-05-27 18:38 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, linux-kernel, Gustavo A. R. Silva
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) {
--
2.21.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] macvlan: Replace strncpy() by strscpy()
2019-05-27 18:38 [PATCH net-next] macvlan: Replace strncpy() by strscpy() Gustavo A. R. Silva
@ 2019-05-27 21:20 ` Stephen Hemminger
2019-05-27 21:28 ` Gustavo A. R. Silva
2019-05-29 7:00 ` David Miller
2019-05-29 7:01 ` David Miller
2 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2019-05-27 21:20 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: David S. Miller, netdev, linux-kernel
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?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] macvlan: Replace strncpy() by strscpy()
2019-05-27 21:20 ` Stephen Hemminger
@ 2019-05-27 21:28 ` Gustavo A. R. Silva
2019-05-27 21:33 ` Stephen Hemminger
0 siblings, 1 reply; 6+ messages in thread
From: Gustavo A. R. Silva @ 2019-05-27 21:28 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David S. Miller, netdev, linux-kernel
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] macvlan: Replace strncpy() by strscpy()
2019-05-27 21:28 ` Gustavo A. R. Silva
@ 2019-05-27 21:33 ` Stephen Hemminger
0 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2019-05-27 21:33 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: David S. Miller, netdev, linux-kernel
On Mon, 27 May 2019 16:28:05 -0500
"Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:
> 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.
Are you going to fix all these:
$ git grep strlcpy | grep IFNAMSIZ| wc -l
47
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] macvlan: Replace strncpy() by strscpy()
2019-05-27 18:38 [PATCH net-next] macvlan: Replace strncpy() by strscpy() Gustavo A. R. Silva
2019-05-27 21:20 ` Stephen Hemminger
@ 2019-05-29 7:00 ` David Miller
2019-05-29 7:01 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-05-29 7:00 UTC (permalink / raw)
To: gustavo; +Cc: netdev, linux-kernel
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Mon, 27 May 2019 13:38:55 -0500
> 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>
Applied.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] macvlan: Replace strncpy() by strscpy()
2019-05-27 18:38 [PATCH net-next] macvlan: Replace strncpy() by strscpy() Gustavo A. R. Silva
2019-05-27 21:20 ` Stephen Hemminger
2019-05-29 7:00 ` David Miller
@ 2019-05-29 7:01 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-05-29 7:01 UTC (permalink / raw)
To: gustavo; +Cc: netdev, linux-kernel
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Mon, 27 May 2019 13:38:55 -0500
> 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>
Applied.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-05-29 7:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27 18:38 [PATCH net-next] macvlan: Replace strncpy() by strscpy() Gustavo A. R. Silva
2019-05-27 21:20 ` Stephen Hemminger
2019-05-27 21:28 ` Gustavo A. R. Silva
2019-05-27 21:33 ` Stephen Hemminger
2019-05-29 7:00 ` David Miller
2019-05-29 7:01 ` David Miller
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).