]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: l2tp_eth: Replace deprecated strcpy with strscpy in l2tp_eth_create
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 23 Feb 2026 07:41:34 +0000 (08:41 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 24 Feb 2026 12:38:33 +0000 (13:38 +0100)
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
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>
net/l2tp/l2tp_eth.c

index cf0b66f4fb29b6c0337a5f90d940b078c86895a4..a4956ef9574ccd879c7ed1705804dabe1630f7c8 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/in.h>
 #include <linux/etherdevice.h>
 #include <linux/spinlock.h>
+#include <linux/string.h>
 #include <net/sock.h>
 #include <net/ip.h>
 #include <net/icmp.h>
@@ -235,10 +236,10 @@ static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel,
        int rc;
 
        if (cfg->ifname) {
-               strscpy(name, cfg->ifname, IFNAMSIZ);
+               strscpy(name, cfg->ifname);
                name_assign_type = NET_NAME_USER;
        } else {
-               strcpy(name, L2TP_ETH_DEV_NAME);
+               strscpy(name, L2TP_ETH_DEV_NAME);
                name_assign_type = NET_NAME_ENUM;
        }