Commit 11379b5e authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

cifs: fix cifsConvertToUCS() for the mapchars case

As Metze pointed out, commit 84cdf74e broke mapchars option:

    Commit "cifs: fix unaligned accesses in cifsConvertToUCS"
    (84cdf74e) does multiple steps
    in just one commit (moving the function and changing it without
    testing).

    put_unaligned_le16(temp, &target[j]); is never called for any
    codepoint the goes via the 'default' switch statement. As a result
    we put just zero (or maybe uninitialized) bytes into the target
    buffer.

His proposed patch looks correct, but doesn't apply to the current head
of the tree. This patch should also fix it.

Cc: <stable@kernel.org> # .38.x: 581ade4d: cifs: clean up various nits in unicode routines (try #2)
Reported-by: default avatarStefan Metzmacher <metze@samba.org>
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 221d1d79
...@@ -277,6 +277,7 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen, ...@@ -277,6 +277,7 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen,
for (i = 0, j = 0; i < srclen; j++) { for (i = 0, j = 0; i < srclen; j++) {
src_char = source[i]; src_char = source[i];
charlen = 1;
switch (src_char) { switch (src_char) {
case 0: case 0:
put_unaligned(0, &target[j]); put_unaligned(0, &target[j]);
...@@ -316,16 +317,13 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen, ...@@ -316,16 +317,13 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen,
dst_char = cpu_to_le16(0x003f); dst_char = cpu_to_le16(0x003f);
charlen = 1; charlen = 1;
} }
}
/* /*
* character may take more than one byte in the source * character may take more than one byte in the source string,
* string, but will take exactly two bytes in the * but will take exactly two bytes in the target string
* target string
*/ */
i += charlen; i += charlen;
continue;
}
put_unaligned(dst_char, &target[j]); put_unaligned(dst_char, &target[j]);
i++; /* move to next char in source string */
} }
ctoUCS_out: ctoUCS_out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment