Skip to content

Commit

Permalink
[CIFS] fix mount failure with broken pathnames when smb3 mount with m…
Browse files Browse the repository at this point in the history
…apchars option

When we SMB3 mounted with mapchars (to allow reserved characters : \ / > < * ?
via the Unicode Windows to POSIX remap range) empty paths
(eg when we open "" to query the root of the SMB3 directory on mount) were not
null terminated so we sent garbarge as a path name on empty paths which caused
SMB2/SMB2.1/SMB3 mounts to fail when mapchars was specified.  mapchars is
particularly important since Unix Extensions for SMB3 are not supported (yet)

Signed-off-by: Steve French <[email protected]>
Cc: <[email protected]>
Reviewed-by: David Disseldorp <[email protected]>
  • Loading branch information
smfrench committed Jun 24, 2014
1 parent 08bc035 commit ce36d9a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/cifs/cifs_unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,20 @@ int
cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
const struct nls_table *cp, int mapChars)
{
int i, j, charlen;
int i, charlen;
int j = 0;
char src_char;
__le16 dst_char;
wchar_t tmp;

if (!mapChars)
return cifs_strtoUTF16(target, source, PATH_MAX, cp);

for (i = 0, j = 0; i < srclen; j++) {
for (i = 0; i < srclen; j++) {
src_char = source[i];
charlen = 1;
switch (src_char) {
case 0:
put_unaligned(0, &target[j]);
goto ctoUTF16_out;
case ':':
dst_char = cpu_to_le16(UNI_COLON);
Expand Down Expand Up @@ -350,6 +350,7 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
}

ctoUTF16_out:
put_unaligned(0, &target[j]); /* Null terminate target unicode string */
return j;
}

Expand Down

0 comments on commit ce36d9a

Please sign in to comment.