]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
orangefs: Replace deprecated strcpy with strscpy
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 22 Dec 2025 10:00:57 +0000 (11:00 +0100)
committerMike Marshall <hubcap@omnibond.com>
Mon, 19 Jan 2026 21:00:51 +0000 (16:00 -0500)
strcpy() has been deprecated [1] because it performs no bounds checking
on the destination buffer, which can lead to buffer overflows. Replace
it with the safer strscpy().  No functional changes.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
fs/orangefs/xattr.c

index eee3c5ed1bbbb8472ddad28b4afedfe0501bdb5d..a431aa07a2290149b6230c89d5b4861433b36414 100644 (file)
@@ -152,7 +152,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
                goto out_unlock;
 
        new_op->upcall.req.getxattr.refn = orangefs_inode->refn;
-       strcpy(new_op->upcall.req.getxattr.key, name);
+       strscpy(new_op->upcall.req.getxattr.key, name);
 
        /*
         * NOTE: Although keys are meant to be NULL terminated textual
@@ -173,7 +173,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
                                     (char *)new_op->upcall.req.getxattr.key);
                        cx = kmalloc(sizeof *cx, GFP_KERNEL);
                        if (cx) {
-                               strcpy(cx->key, name);
+                               strscpy(cx->key, name);
                                cx->length = -1;
                                cx->timeout = jiffies +
                                    orangefs_getattr_timeout_msecs*HZ/1000;
@@ -220,14 +220,14 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
        ret = length;
 
        if (cx) {
-               strcpy(cx->key, name);
+               strscpy(cx->key, name);
                memcpy(cx->val, buffer, length);
                cx->length = length;
                cx->timeout = jiffies + HZ;
        } else {
                cx = kmalloc(sizeof *cx, GFP_KERNEL);
                if (cx) {
-                       strcpy(cx->key, name);
+                       strscpy(cx->key, name);
                        memcpy(cx->val, buffer, length);
                        cx->length = length;
                        cx->timeout = jiffies + HZ;
@@ -267,7 +267,7 @@ static int orangefs_inode_removexattr(struct inode *inode, const char *name,
         * textual strings, I am going to explicitly pass the
         * length just in case we change this later on...
         */
-       strcpy(new_op->upcall.req.removexattr.key, name);
+       strscpy(new_op->upcall.req.removexattr.key, name);
        new_op->upcall.req.removexattr.key_sz = strlen(name) + 1;
 
        gossip_debug(GOSSIP_XATTR_DEBUG,
@@ -361,7 +361,7 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name,
         * strings, I am going to explicitly pass the length just in
         * case we change this later on...
         */
-       strcpy(new_op->upcall.req.setxattr.keyval.key, name);
+       strscpy(new_op->upcall.req.setxattr.keyval.key, name);
        new_op->upcall.req.setxattr.keyval.key_sz = strlen(name) + 1;
        memcpy(new_op->upcall.req.setxattr.keyval.val, value, size);
        new_op->upcall.req.setxattr.keyval.val_sz = size;