From: "Miquel Sabaté Solà" <mssola@mssola.com>
To: linux-fsdevel@vger.kernel.org
Cc: miklos@szeredi.hu, linux-kernel@vger.kernel.org,
"Miquel Sabaté Solà" <mssola@mssola.com>
Subject: [PATCH v2 1/2] fs: fuse: Use strscpy instead of strcpy
Date: Mon, 29 Sep 2025 15:02:45 +0200 [thread overview]
Message-ID: <20250929130246.107478-2-mssola@mssola.com> (raw)
In-Reply-To: <20250929130246.107478-1-mssola@mssola.com>
As pointed out in [1], strcpy() is deprecated in favor of
strscpy().
Furthermore, the length of the name to be copied is well known at this
point since we are going to move the pointer by that much on the next
line. Hence, it's safe to assume 'namelen' for the length of the string
to be copied.
[1] https://github.com/KSPP/linux/issues/88
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
---
fs/fuse/dir.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index ecaec0fea3a1..3809e280b157 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -504,7 +504,7 @@ static int get_security_context(struct dentry *entry, umode_t mode,
fctx->size = lsmctx.len;
ptr += sizeof(*fctx);
- strcpy(ptr, name);
+ strscpy(ptr, name, namelen);
ptr += namelen;
memcpy(ptr, lsmctx.context, lsmctx.len);
--
2.51.0
next prev parent reply other threads:[~2025-09-29 13:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 13:02 [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy Miquel Sabaté Solà
2025-09-29 13:02 ` Miquel Sabaté Solà [this message]
2025-09-29 13:02 ` [PATCH v2 2/2] fs: fuse: rename 'namelen' to 'namesize' Miquel Sabaté Solà
2025-10-15 9:40 ` [PATCH v2 0/2] fs: fuse: use strscpy instead of strcpy Miquel Sabaté Solà
2025-11-13 9:38 ` Miklos Szeredi
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=20250929130246.107478-2-mssola@mssola.com \
--to=mssola@mssola.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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).