cifs: move from strlcpy with unused retval to strscpy
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 18 Aug 2022 21:01:41 +0000 (23:01 +0200)
committerSteve French <stfrench@microsoft.com>
Fri, 19 Aug 2022 16:02:26 +0000 (11:02 -0500)
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifsroot.c
fs/cifs/connect.c
fs/cifs/smb2pdu.c

index 9e91a5a..56ec1b2 100644 (file)
@@ -59,7 +59,7 @@ static int __init cifs_root_setup(char *line)
                        pr_err("Root-CIFS: UNC path too long\n");
                        return 1;
                }
-               strlcpy(root_dev, line, len);
+               strscpy(root_dev, line, len);
                srvaddr = parse_srvaddr(&line[2], s);
                if (*s) {
                        int n = snprintf(root_opts,
index 9111c02..3da5da9 100644 (file)
@@ -3994,7 +3994,7 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
                }
                bcc_ptr += length + 1;
                bytes_left -= (length + 1);
-               strlcpy(tcon->treeName, tree, sizeof(tcon->treeName));
+               strscpy(tcon->treeName, tree, sizeof(tcon->treeName));
 
                /* mostly informational -- no need to fail on error here */
                kfree(tcon->nativeFileSystem);
index 918152f..91cfc5b 100644 (file)
@@ -1928,7 +1928,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
        tcon->capabilities = rsp->Capabilities; /* we keep caps little endian */
        tcon->maximal_access = le32_to_cpu(rsp->MaximalAccess);
        tcon->tid = le32_to_cpu(rsp->hdr.Id.SyncId.TreeId);
-       strlcpy(tcon->treeName, tree, sizeof(tcon->treeName));
+       strscpy(tcon->treeName, tree, sizeof(tcon->treeName));
 
        if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) &&
            ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0))