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.

mm/memfd: replace deprecated strcpy() with memcpy() in alloc_name()

strcpy() is deprecated; use memcpy() instead.

Not copying the NUL terminator is safe because strncpy_from_user() would
overwrite it anyway by appending uname to the destination buffer at index
MFD_NAME_PREFIX_LEN.

No functional changes intended.

Link: https://github.com/KSPP/linux/issues/88
Link: https://lkml.kernel.org/r/20250712174516.64243-2-thorsten.blum@linux.dev
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Thorsten Blum and committed by
Andrew Morton
5bd88fef 5add26c0

+1 -1
+1 -1
mm/memfd.c
··· 411 411 if (!name) 412 412 return ERR_PTR(-ENOMEM); 413 413 414 - strcpy(name, MFD_NAME_PREFIX); 414 + memcpy(name, MFD_NAME_PREFIX, MFD_NAME_PREFIX_LEN); 415 415 /* returned length does not include terminating zero */ 416 416 len = strncpy_from_user(&name[MFD_NAME_PREFIX_LEN], uname, MFD_NAME_MAX_LEN + 1); 417 417 if (len < 0) {