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

net/netrom: prefer strscpy over strcpy

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-4-lihongbo22@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Hongbo Li and committed by
Jakub Kicinski
597be7bd b19f69a9

+2 -2
+2 -2
net/netrom/nr_route.c
··· 189 189 } 190 190 191 191 nr_node->callsign = *nr; 192 - strcpy(nr_node->mnemonic, mnemonic); 192 + strscpy(nr_node->mnemonic, mnemonic); 193 193 194 194 nr_node->which = 0; 195 195 nr_node->count = 1; ··· 214 214 nr_node_lock(nr_node); 215 215 216 216 if (quality != 0) 217 - strcpy(nr_node->mnemonic, mnemonic); 217 + strscpy(nr_node->mnemonic, mnemonic); 218 218 219 219 for (found = 0, i = 0; i < nr_node->count; i++) { 220 220 if (nr_node->routes[i].neighbour == nr_neigh) {