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.

ipv4: ip_tunnel: Replace strcpy use with strscpy

Use of strcpy is decpreated, replaces the use of strcpy with strscpy as
recommended.

strscpy was chosen as it requires a NUL terminated non-padded string,
which is the case here.

I am aware there is an explicit bounds check above the second instance,
however using strscpy protects against buffer overflows in any future
code, and there is no good reason I can see to not use it.

I have also replaced the scrscpy above that had 3 params with the
version using 2 params. These are functionally equivalent, but it is
cleaner to have both using 2 params.

Signed-off-by: Ruben Wauters <rubenru09@aol.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250501202935.46318-1-rubenru09@aol.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ruben Wauters and committed by
Jakub Kicinski
c2dbda07 f267eeee

+2 -2
+2 -2
net/ipv4/ip_tunnel.c
··· 243 243 if (parms->name[0]) { 244 244 if (!dev_valid_name(parms->name)) 245 245 goto failed; 246 - strscpy(name, parms->name, IFNAMSIZ); 246 + strscpy(name, parms->name); 247 247 } else { 248 248 if (strlen(ops->kind) > (IFNAMSIZ - 3)) 249 249 goto failed; 250 - strcpy(name, ops->kind); 250 + strscpy(name, ops->kind); 251 251 strcat(name, "%d"); 252 252 } 253 253