提交 ce36d9ab 编写于 作者: S Steve French

[CIFS] fix mount failure with broken pathnames when smb3 mount with mapchars 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: NSteve French <smfrench@gmail.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: NDavid Disseldorp <ddiss@suse.de>
上级 08bc0353
...@@ -290,7 +290,8 @@ int ...@@ -290,7 +290,8 @@ int
cifsConvertToUTF16(__le16 *target, const char *source, int srclen, cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
const struct nls_table *cp, int mapChars) const struct nls_table *cp, int mapChars)
{ {
int i, j, charlen; int i, charlen;
int j = 0;
char src_char; char src_char;
__le16 dst_char; __le16 dst_char;
wchar_t tmp; wchar_t tmp;
...@@ -298,12 +299,11 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen, ...@@ -298,12 +299,11 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
if (!mapChars) if (!mapChars)
return cifs_strtoUTF16(target, source, PATH_MAX, cp); 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]; src_char = source[i];
charlen = 1; charlen = 1;
switch (src_char) { switch (src_char) {
case 0: case 0:
put_unaligned(0, &target[j]);
goto ctoUTF16_out; goto ctoUTF16_out;
case ':': case ':':
dst_char = cpu_to_le16(UNI_COLON); dst_char = cpu_to_le16(UNI_COLON);
...@@ -350,6 +350,7 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen, ...@@ -350,6 +350,7 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
} }
ctoUTF16_out: ctoUTF16_out:
put_unaligned(0, &target[j]); /* Null terminate target unicode string */
return j; return j;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册