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

net/rds: Replace deprecated strncpy() with strscpy_pad()

strncpy() is deprecated for NUL-terminated destination buffers. Use
strscpy_pad() instead and remove the manual NUL-termination.

Compile-tested only.

Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Kees Cook <kees@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Tested-by: Allison Henderson <allison.henderson@oracle.com>
Link: https://patch.msgid.link/20250219224730.73093-2-thorsten.blum@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Thorsten Blum and committed by
Jakub Kicinski
c451715d 376cd9a2

+1 -2
+1 -2
net/rds/stats.c
··· 89 89 90 90 for (i = 0; i < nr; i++) { 91 91 BUG_ON(strlen(names[i]) >= sizeof(ctr.name)); 92 - strncpy(ctr.name, names[i], sizeof(ctr.name) - 1); 93 - ctr.name[sizeof(ctr.name) - 1] = '\0'; 92 + strscpy_pad(ctr.name, names[i]); 94 93 ctr.value = values[i]; 95 94 96 95 rds_info_copy(iter, &ctr, sizeof(ctr));