diff options
author | Ronnie Sahlberg <lsahlber@redhat.com> | 2019-08-27 09:30:14 +1000 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2019-08-27 17:25:12 -0500 |
commit | 340625e618e1b37a72a02f07aa7144ae0ab0b19e (patch) | |
tree | 9bac6626dd3e1477a93301a84c7c797b7db5526c /fs/cifs/dir.c | |
parent | 478228e57f81f6cb60798d54fc02a74ea7dd267e (diff) | |
download | linux-340625e618e1b37a72a02f07aa7144ae0ab0b19e.tar.bz2 |
cifs: replace various strncpy with strscpy and similar
Using strscpy is cleaner, and avoids some problems with
handling maximum length strings. Linus noticed the
original problem and Aurelien pointed out some additional
problems. Fortunately most of this is SMB1 code (and
in particular the ASCII string handling older, which
is less common).
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'fs/cifs/dir.c')
-rw-r--r-- | fs/cifs/dir.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index f26a48dd2e39..be424e81e3ad 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -69,11 +69,10 @@ cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb, return full_path; if (dfsplen) - strncpy(full_path, tcon->treeName, dfsplen); + memcpy(full_path, tcon->treeName, dfsplen); full_path[dfsplen] = CIFS_DIR_SEP(cifs_sb); - strncpy(full_path + dfsplen + 1, vol->prepath, pplen); + memcpy(full_path + dfsplen + 1, vol->prepath, pplen); convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb)); - full_path[dfsplen + pplen] = 0; /* add trailing null */ return full_path; } |