From: Paulo Alcantara Date: Wed, 14 Nov 2018 16:03:40 +0000 (-0200) Subject: cifs: Skip any trailing backslashes from UNC X-Git-Tag: v5.4-rc1~1890^2~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c34fea5a636d98607ee6e41c78acc9d5ca8fb756;p=platform%2Fkernel%2Flinux-rpi.git 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 Reviewed-by: Aurelien Aptel Signed-off-by: Steve French --- diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 944188d..bab4422 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, '\\');