Skip to contentSkip to conversation

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

PATCH Applied Thorsten Blum 1 participant 1 message Jul 12, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 mm/memfd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memfd.c +1 -1
index ab367e61553d..6f4db997b955 100644
@@ -401,7 +401,7 @@ static char *alloc_name(const char __user *uname)
 	if (!name)
 		return ERR_PTR(-ENOMEM);
 
-	strcpy(name, MFD_NAME_PREFIX);
+	memcpy(name, MFD_NAME_PREFIX, MFD_NAME_PREFIX_LEN);
 	/* returned length does not include terminating zero */
 	len = strncpy_from_user(&name[MFD_NAME_PREFIX_LEN], uname, MFD_NAME_MAX_LEN + 1);
 	if (len < 0) {
Signature · 1 line
2.50.0