* [PATCH] cifs: move from strlcpy with unused retval to strscpy
@ 2022-08-18 21:01 Wolfram Sang
2022-08-19 5:00 ` Steve French
0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2022-08-18 21:01 UTC (permalink / raw)
To: linux-kernel
Cc: Wolfram Sang, Steve French, Paulo Alcantara, Ronnie Sahlberg,
Shyam Prasad N, linux-cifs, samba-technical
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>
---
fs/cifs/cifsroot.c | 2 +-
fs/cifs/connect.c | 2 +-
fs/cifs/smb2pdu.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/cifs/cifsroot.c b/fs/cifs/cifsroot.c
index 9e91a5a40aae..56ec1b233f52 100644
--- a/fs/cifs/cifsroot.c
+++ b/fs/cifs/cifsroot.c
@@ -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,
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 9111c025bcb8..3da5da9f16b0 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -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);
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 9b31ea946d45..9958b5f1c12f 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -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))
--
2.35.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] cifs: move from strlcpy with unused retval to strscpy
2022-08-18 21:01 [PATCH] cifs: move from strlcpy with unused retval to strscpy Wolfram Sang
@ 2022-08-19 5:00 ` Steve French
2022-08-19 5:48 ` Wolfram Sang
2022-08-19 6:20 ` Steve French
0 siblings, 2 replies; 4+ messages in thread
From: Steve French @ 2022-08-19 5:00 UTC (permalink / raw)
To: Wolfram Sang
Cc: LKML, Steve French, Paulo Alcantara, Ronnie Sahlberg,
Shyam Prasad N, CIFS, samba-technical
Looks fine. Do you want this merged through my tree?
On Thu, Aug 18, 2022 at 4:11 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> 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>
> ---
> fs/cifs/cifsroot.c | 2 +-
> fs/cifs/connect.c | 2 +-
> fs/cifs/smb2pdu.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/cifs/cifsroot.c b/fs/cifs/cifsroot.c
> index 9e91a5a40aae..56ec1b233f52 100644
> --- a/fs/cifs/cifsroot.c
> +++ b/fs/cifs/cifsroot.c
> @@ -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,
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 9111c025bcb8..3da5da9f16b0 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -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);
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index 9b31ea946d45..9958b5f1c12f 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -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))
> --
> 2.35.1
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] cifs: move from strlcpy with unused retval to strscpy
2022-08-19 5:00 ` Steve French
@ 2022-08-19 5:48 ` Wolfram Sang
2022-08-19 6:20 ` Steve French
1 sibling, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2022-08-19 5:48 UTC (permalink / raw)
To: Steve French
Cc: LKML, Steve French, Paulo Alcantara, Ronnie Sahlberg,
Shyam Prasad N, CIFS, samba-technical
[-- Attachment #1: Type: text/plain, Size: 134 bytes --]
On Fri, Aug 19, 2022 at 12:00:34AM -0500, Steve French wrote:
> Looks fine. Do you want this merged through my tree?
Yes, please.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cifs: move from strlcpy with unused retval to strscpy
2022-08-19 5:00 ` Steve French
2022-08-19 5:48 ` Wolfram Sang
@ 2022-08-19 6:20 ` Steve French
1 sibling, 0 replies; 4+ messages in thread
From: Steve French @ 2022-08-19 6:20 UTC (permalink / raw)
To: Wolfram Sang
Cc: LKML, Steve French, Paulo Alcantara, Ronnie Sahlberg,
Shyam Prasad N, CIFS, samba-technical
tentatively merged into cifs-2.6.git for-next pending testing
On Fri, Aug 19, 2022 at 12:00 AM Steve French <smfrench@gmail.com> wrote:
>
> Looks fine. Do you want this merged through my tree?
>
> On Thu, Aug 18, 2022 at 4:11 PM Wolfram Sang
> <wsa+renesas@sang-engineering.com> wrote:
> >
> > 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>
> > ---
> > fs/cifs/cifsroot.c | 2 +-
> > fs/cifs/connect.c | 2 +-
> > fs/cifs/smb2pdu.c | 2 +-
> > 3 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/cifs/cifsroot.c b/fs/cifs/cifsroot.c
> > index 9e91a5a40aae..56ec1b233f52 100644
> > --- a/fs/cifs/cifsroot.c
> > +++ b/fs/cifs/cifsroot.c
> > @@ -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,
> > diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> > index 9111c025bcb8..3da5da9f16b0 100644
> > --- a/fs/cifs/connect.c
> > +++ b/fs/cifs/connect.c
> > @@ -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);
> > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> > index 9b31ea946d45..9958b5f1c12f 100644
> > --- a/fs/cifs/smb2pdu.c
> > +++ b/fs/cifs/smb2pdu.c
> > @@ -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))
> > --
> > 2.35.1
> >
>
>
> --
> Thanks,
>
> Steve
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-08-19 6:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18 21:01 [PATCH] cifs: move from strlcpy with unused retval to strscpy Wolfram Sang
2022-08-19 5:00 ` Steve French
2022-08-19 5:48 ` Wolfram Sang
2022-08-19 6:20 ` Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®