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.

net: l2tp_eth: Replace deprecated strcpy with strscpy in l2tp_eth_create

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 'cfg->ifname'.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260223074137.321862-1-thorsten.blum@linux.dev
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Thorsten Blum and committed by
Paolo Abeni
e5a80f5e 8ac768bb

+3 -2
+3 -2
net/l2tp/l2tp_eth.c
··· 14 14 #include <linux/in.h> 15 15 #include <linux/etherdevice.h> 16 16 #include <linux/spinlock.h> 17 + #include <linux/string.h> 17 18 #include <net/sock.h> 18 19 #include <net/ip.h> 19 20 #include <net/icmp.h> ··· 236 235 int rc; 237 236 238 237 if (cfg->ifname) { 239 - strscpy(name, cfg->ifname, IFNAMSIZ); 238 + strscpy(name, cfg->ifname); 240 239 name_assign_type = NET_NAME_USER; 241 240 } else { 242 - strcpy(name, L2TP_ETH_DEV_NAME); 241 + strscpy(name, L2TP_ETH_DEV_NAME); 243 242 name_assign_type = NET_NAME_ENUM; 244 243 } 245 244