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

net/ipv6: replace deprecated strcpy with strscpy

The deprecated helper strcpy() performs no bounds checking on the
destination buffer. This could result in linear overflows beyond
the end of the buffer, leading to all kinds of misbehaviors.
The safe replacement is strscpy() [1].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Link: https://patch.msgid.link/20240828123224.3697672-3-lihongbo22@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Hongbo Li and committed by
Jakub Kicinski
b19f69a9 68016b99

+1 -1
+1 -1
net/ipv6/ndisc.c
··· 1944 1944 static char warncomm[TASK_COMM_LEN]; 1945 1945 static int warned; 1946 1946 if (strcmp(warncomm, current->comm) && warned < 5) { 1947 - strcpy(warncomm, current->comm); 1947 + strscpy(warncomm, current->comm); 1948 1948 pr_warn("process `%s' is using deprecated sysctl (%s) net.ipv6.neigh.%s.%s - use net.ipv6.neigh.%s.%s_ms instead\n", 1949 1949 warncomm, func, 1950 1950 dev_name, ctl->procname,