]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fuse: use strscpy instead of strcpy
authorMiquel Sabaté Solà <mssola@mssola.com>
Mon, 29 Sep 2025 13:02:45 +0000 (15:02 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Thu, 13 Nov 2025 09:36:44 +0000 (10:36 +0100)
As pointed out in [1], strcpy() is deprecated in favor of strscpy().

Furthermore, the size of the buffer for 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 size of the string
to be copied.

[1] https://github.com/KSPP/linux/issues/88

Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/dir.c

index 8ef8134e1cd5dc13ba75f22abd5ae626d8dbcebb..70f364aa65412ab9357b5519bb3438480cbfc90b 100644 (file)
@@ -699,7 +699,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);