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, '\\');