summaryrefslogtreecommitdiff
path: root/fs/cifs/unc.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2021-03-05 15:02:34 -0500
committerSteve French <stfrench@microsoft.com>2021-04-25 16:28:23 -0500
commit8d7672235533dbeab4a5373b49f1b4273cdc2c6a (patch)
treee86654fbc3d834f515bcc97d77f36ae7ba5649d4 /fs/cifs/unc.c
parentb9335f621064b95bbf3e9473e228c4b328ff3e8a (diff)
downloadlinux-next-8d7672235533dbeab4a5373b49f1b4273cdc2c6a.tar.gz
cifs: don't cargo-cult strndup()
strndup(s, strlen(s)) is a highly unidiomatic way to spell strdup(s); it's *NOT* safer in any way, since strlen() is just as sensitive to NUL-termination as strdup() is. strndup() is for situations when you need a copy of a known-sized substring, not a magic security juju to drive the bad spirits away. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/unc.c')
-rw-r--r--fs/cifs/unc.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/fs/cifs/unc.c b/fs/cifs/unc.c
index 394aa00cea40..f6fc5e343ea4 100644
--- a/fs/cifs/unc.c
+++ b/fs/cifs/unc.c
@@ -50,7 +50,6 @@ char *extract_sharename(const char *unc)
{
const char *src;
char *delim, *dst;
- int len;
/* skip double chars at the beginning */
src = unc + 2;
@@ -60,10 +59,9 @@ char *extract_sharename(const char *unc)
if (!delim)
return ERR_PTR(-EINVAL);
delim++;
- len = strlen(delim);
/* caller has to free the memory */
- dst = kstrndup(delim, len, GFP_KERNEL);
+ dst = kstrdup(delim, GFP_KERNEL);
if (!dst)
return ERR_PTR(-ENOMEM);