diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2021-03-05 21:02:34 +0100 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2021-04-25 23:28:23 +0200 |
commit | 8d7672235533dbeab4a5373b49f1b4273cdc2c6a (patch) | |
tree | e86654fbc3d834f515bcc97d77f36ae7ba5649d4 /fs/cifs/misc.c | |
parent | SMB3: update structures for new compression protocol definitions (diff) | |
download | linux-8d7672235533dbeab4a5373b49f1b4273cdc2c6a.tar.xz linux-8d7672235533dbeab4a5373b49f1b4273cdc2c6a.zip |
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/misc.c')
-rw-r--r-- | fs/cifs/misc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 82e176720ca6..c15a90e422be 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c @@ -1180,7 +1180,7 @@ int update_super_prepath(struct cifs_tcon *tcon, char *prefix) kfree(cifs_sb->prepath); if (prefix && *prefix) { - cifs_sb->prepath = kstrndup(prefix, strlen(prefix), GFP_ATOMIC); + cifs_sb->prepath = kstrdup(prefix, GFP_ATOMIC); if (!cifs_sb->prepath) { rc = -ENOMEM; goto out; |