* [PATCH] ipv6: replace sprintf() with no format specifiers with strscpy()
@ 2026-09-09 21:05 Lalit Shankar Chowdhury
2026-09-10 7:09 ` Hangbin Liu
2026-09-10 10:54 ` David Laight
0 siblings, 2 replies; 3+ messages in thread
From: Lalit Shankar Chowdhury @ 2026-09-09 21:05 UTC (permalink / raw)
To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Steffen Klassert,
Herbert Xu, open list:NETWORKING [IPv4/IPv6],
open list
Cc: Lalit Shankar Chowdhury
Multiple instances of sprintf() have no format specifiers. Replace
them with strscpy().
Signed-off-by: Lalit Shankar Chowdhury <lalitshankarch@gmail.com>
---
net/ipv6/ip6_tunnel.c | 2 +-
net/ipv6/ip6_vti.c | 2 +-
net/ipv6/ip6mr.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index d5ff50a2ac01..ef3a6d931c9e 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -294,7 +294,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
goto failed;
strscpy(name, p->name, IFNAMSIZ);
} else {
- sprintf(name, "ip6tnl%%d");
+ strscpy(name, "ip6tnl%d", IFNAMSIZ);
}
err = -ENOMEM;
dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index ab94b3a4ba9c..182a7949d830 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -210,7 +210,7 @@ static struct ip6_tnl *vti6_tnl_create(struct net *net, struct __ip6_tnl_parm *p
goto failed;
strscpy(name, p->name, IFNAMSIZ);
} else {
- sprintf(name, "ip6_vti%%d");
+ strscpy(name, "ip6_vti%d", IFNAMSIZ);
}
dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, vti6_dev_setup);
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 3f2ed9b77deb..20ac8cb87468 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -692,7 +692,7 @@ static struct net_device *ip6mr_reg_vif(struct net *net, struct mr_table *mrt)
char name[IFNAMSIZ];
if (mrt->id == RT6_TABLE_DFLT)
- sprintf(name, "pim6reg");
+ strscpy(name, "pim6reg", IFNAMSIZ);
else
sprintf(name, "pim6reg%u", mrt->id);
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ipv6: replace sprintf() with no format specifiers with strscpy()
2026-09-09 21:05 [PATCH] ipv6: replace sprintf() with no format specifiers with strscpy() Lalit Shankar Chowdhury
@ 2026-09-10 7:09 ` Hangbin Liu
2026-09-10 10:54 ` David Laight
1 sibling, 0 replies; 3+ messages in thread
From: Hangbin Liu @ 2026-09-10 7:09 UTC (permalink / raw)
To: Lalit Shankar Chowdhury
Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Steffen Klassert,
Herbert Xu, open list:NETWORKING [IPv4/IPv6],
open list
Hi Lalit,
On Wed, Sep 09, 2026 at 09:05:52PM +0000, Lalit Shankar Chowdhury wrote:
> Multiple instances of sprintf() have no format specifiers. Replace
> them with strscpy().
>
> Signed-off-by: Lalit Shankar Chowdhury <lalitshankarch@gmail.com>
> ---
> net/ipv6/ip6_tunnel.c | 2 +-
> net/ipv6/ip6_vti.c | 2 +-
> net/ipv6/ip6mr.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> index d5ff50a2ac01..ef3a6d931c9e 100644
> --- a/net/ipv6/ip6_tunnel.c
> +++ b/net/ipv6/ip6_tunnel.c
> @@ -294,7 +294,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
> goto failed;
> strscpy(name, p->name, IFNAMSIZ);
> } else {
> - sprintf(name, "ip6tnl%%d");
> + strscpy(name, "ip6tnl%d", IFNAMSIZ);
The sprintf() is doing format expansion (%% -> %), the name will be used
in __dev_alloc_name() later. I think there is no need to change them.
Thanks
Hangbin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ipv6: replace sprintf() with no format specifiers with strscpy()
2026-09-09 21:05 [PATCH] ipv6: replace sprintf() with no format specifiers with strscpy() Lalit Shankar Chowdhury
2026-09-10 7:09 ` Hangbin Liu
@ 2026-09-10 10:54 ` David Laight
1 sibling, 0 replies; 3+ messages in thread
From: David Laight @ 2026-09-10 10:54 UTC (permalink / raw)
To: Lalit Shankar Chowdhury
Cc: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Steffen Klassert,
Herbert Xu, open list:NETWORKING [IPv4/IPv6],
open list
On Wed, 9 Sep 2026 21:05:52 +0000
Lalit Shankar Chowdhury <lalitshankarch@gmail.com> wrote:
> Multiple instances of sprintf() have no format specifiers. Replace
> them with strscpy().
>
> Signed-off-by: Lalit Shankar Chowdhury <lalitshankarch@gmail.com>
> ---
> net/ipv6/ip6_tunnel.c | 2 +-
> net/ipv6/ip6_vti.c | 2 +-
> net/ipv6/ip6mr.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> index d5ff50a2ac01..ef3a6d931c9e 100644
> --- a/net/ipv6/ip6_tunnel.c
> +++ b/net/ipv6/ip6_tunnel.c
> @@ -294,7 +294,7 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct __ip6_tnl_parm *p)
> goto failed;
> strscpy(name, p->name, IFNAMSIZ);
> } else {
> - sprintf(name, "ip6tnl%%d");
> + strscpy(name, "ip6tnl%d", IFNAMSIZ);
> }
> err = -ENOMEM;
> dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,
That code is silly, there is no need for the copies at all.
Something like:
if (p->name[0] && !dev_valid_name[p->name])
return ERR_PTR(-E2BIG);
dev = alloc_netdev(sizeof(*t), p->name[0] ? p->name : "op6tnl%d",
NET_NAME_UNKNOWN, ip6_tnl_dev_setup);
if (!dev)
return ERR_PTR(-ENOMEM);
David
> diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
> index ab94b3a4ba9c..182a7949d830 100644
> --- a/net/ipv6/ip6_vti.c
> +++ b/net/ipv6/ip6_vti.c
> @@ -210,7 +210,7 @@ static struct ip6_tnl *vti6_tnl_create(struct net *net, struct __ip6_tnl_parm *p
> goto failed;
> strscpy(name, p->name, IFNAMSIZ);
> } else {
> - sprintf(name, "ip6_vti%%d");
> + strscpy(name, "ip6_vti%d", IFNAMSIZ);
> }
>
> dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, vti6_dev_setup);
> diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
> index 3f2ed9b77deb..20ac8cb87468 100644
> --- a/net/ipv6/ip6mr.c
> +++ b/net/ipv6/ip6mr.c
> @@ -692,7 +692,7 @@ static struct net_device *ip6mr_reg_vif(struct net *net, struct mr_table *mrt)
> char name[IFNAMSIZ];
>
> if (mrt->id == RT6_TABLE_DFLT)
> - sprintf(name, "pim6reg");
> + strscpy(name, "pim6reg", IFNAMSIZ);
> else
> sprintf(name, "pim6reg%u", mrt->id);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-10 10:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-09 21:05 [PATCH] ipv6: replace sprintf() with no format specifiers with strscpy() Lalit Shankar Chowdhury
2026-09-10 7:09 ` Hangbin Liu
2026-09-10 10:54 ` David Laight
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®