linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/memfd: replace strcpy() by strscpy()
@ 2021-01-24  2:23 Stephen Zhang
  2021-01-24  4:06 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Zhang @ 2021-01-24  2:23 UTC (permalink / raw)
  To: akpm; +Cc: linux-mm, linux-kernel, Stephen Zhang

The strcpy() function is being deprecated. Replace it by the safer
strscpy().

Signed-off-by: Stephen Zhang <stephenzhangzsd@gmail.com>
---
 mm/memfd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memfd.c b/mm/memfd.c
index 2647c89..bb90862 100644
--- a/mm/memfd.c
+++ b/mm/memfd.c
@@ -278,7 +278,7 @@ long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
 	if (!name)
 		return -ENOMEM;
 
-	strcpy(name, MFD_NAME_PREFIX);
+	strscpy(name, MFD_NAME_PREFIX, len + MFD_NAME_PREFIX_LEN);
 	if (copy_from_user(&name[MFD_NAME_PREFIX_LEN], uname, len)) {
 		error = -EFAULT;
 		goto err_name;
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-24  4:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-24  2:23 [PATCH] mm/memfd: replace strcpy() by strscpy() Stephen Zhang
2021-01-24  4:06 ` Matthew Wilcox
2021-01-24  4:36   ` Stephen Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).