Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipv6: sit: Replace deprecated strcpy with strscpy

strcpy() has been deprecated [1] because it performs no bounds checking
on the destination buffer, which can lead to buffer overflows. Replace
it with the safer strscpy(). Use the two-argument version of strscpy()
to copy 'parms->name' in ipip6_tunnel_locate().

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20260227004541.798966-3-thorsten.blum@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Thorsten Blum and committed by
Jakub Kicinski
ded4a02e eed562b2

+6 -5
+6 -5
net/ipv6/sit.c
··· 21 21 #include <linux/types.h> 22 22 #include <linux/socket.h> 23 23 #include <linux/sockios.h> 24 + #include <linux/string.h> 24 25 #include <linux/net.h> 25 26 #include <linux/in6.h> 26 27 #include <linux/netdevice.h> ··· 257 256 if (parms->name[0]) { 258 257 if (!dev_valid_name(parms->name)) 259 258 goto failed; 260 - strscpy(name, parms->name, IFNAMSIZ); 259 + strscpy(name, parms->name); 261 260 } else { 262 - strcpy(name, "sit%d"); 261 + strscpy(name, "sit%d"); 263 262 } 264 263 dev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN, 265 264 ipip6_tunnel_setup); ··· 276 275 goto failed_free; 277 276 278 277 if (!parms->name[0]) 279 - strcpy(parms->name, dev->name); 278 + strscpy(parms->name, dev->name); 280 279 281 280 return nt; 282 281 ··· 1443 1442 int err; 1444 1443 1445 1444 tunnel->dev = dev; 1446 - strcpy(tunnel->parms.name, dev->name); 1445 + strscpy(tunnel->parms.name, dev->name); 1447 1446 1448 1447 ipip6_tunnel_bind_dev(dev); 1449 1448 ··· 1864 1863 ipip6_tunnel_clone_6rd(sitn->fb_tunnel_dev, sitn); 1865 1864 ipip6_fb_tunnel_init(sitn->fb_tunnel_dev); 1866 1865 1867 - strcpy(t->parms.name, sitn->fb_tunnel_dev->name); 1866 + strscpy(t->parms.name, sitn->fb_tunnel_dev->name); 1868 1867 return 0; 1869 1868 1870 1869 err_reg_dev: