linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Zhang <stephenzhangzsd@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Stephen Zhang <stephenzhangzsd@gmail.com>
Subject: [PATCH] mm/memfd: replace strcpy() by strscpy()
Date: Sun, 24 Jan 2021 10:23:37 +0800	[thread overview]
Message-ID: <1611455017-2210-1-git-send-email-stephenzhangzsd@gmail.com> (raw)

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


             reply	other threads:[~2021-01-24  2:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-24  2:23 Stephen Zhang [this message]
2021-01-24  4:06 ` [PATCH] mm/memfd: replace strcpy() by strscpy() Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1611455017-2210-1-git-send-email-stephenzhangzsd@gmail.com \
    --to=stephenzhangzsd@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).