diff options
author | Paulo Alcantara <palcantara@suse.de> | 2018-11-14 14:03:40 -0200 |
---|---|---|
committer | Steve French <stfrench@microsoft.com> | 2018-12-23 23:05:05 -0600 |
commit | c34fea5a636d98607ee6e41c78acc9d5ca8fb756 (patch) | |
tree | d805933b5f0b276ede415d7a0d87868108c31c2f | |
parent | 56c762eb9bee330bb4e6d11c589434f2904d3ab6 (diff) | |
download | linux-c34fea5a636d98607ee6e41c78acc9d5ca8fb756.tar.gz linux-c34fea5a636d98607ee6e41c78acc9d5ca8fb756.tar.bz2 linux-c34fea5a636d98607ee6e41c78acc9d5ca8fb756.zip |
cifs: Skip any trailing backslashes from UNC
When extracting hostname from UNC, check for leading backslashes
before trying to remove them.
Signed-off-by: Paulo Alcantara <palcantara@suse.de>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
-rw-r--r-- | fs/cifs/connect.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 944188d6200c..bab4422f5815 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1044,7 +1044,12 @@ extract_hostname(const char *unc) /* skip double chars at beginning of string */ /* BB: check validity of these bytes? */ - src = unc + 2; + if (strlen(unc) < 3) + return ERR_PTR(-EINVAL); + for (src = unc; *src && *src == '\\'; src++) + ; + if (!*src) + return ERR_PTR(-EINVAL); /* delimiter between hostname and sharename is always '\\' now */ delim = strchr(src, '\\'); |