aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2011-05-17 15:28:21 -0400
committerSteve French <sfrench@us.ibm.com>2011-05-17 16:54:04 -0400
commit11379b5e33950048ad66825da7f462b0d0da9d73 (patch)
tree97b6089e15c4ce3daadc7633776dca952e883e6b
parent221d1d797202984cb874e3ed9f1388593d34ee22 (diff)
cifs: fix cifsConvertToUCS() for the mapchars case
As Metze pointed out, commit 84cdf74e broke mapchars option: Commit "cifs: fix unaligned accesses in cifsConvertToUCS" (84cdf74e8096a10dd6acbb870dd404b92f07a756) 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: 581ade4: cifs: clean up various nits in unicode routines (try #2) Reported-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r--fs/cifs/cifs_unicode.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index 23d43cde430..1b2e180b018 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -277,6 +277,7 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen,
277 277
278 for (i = 0, j = 0; i < srclen; j++) { 278 for (i = 0, j = 0; i < srclen; j++) {
279 src_char = source[i]; 279 src_char = source[i];
280 charlen = 1;
280 switch (src_char) { 281 switch (src_char) {
281 case 0: 282 case 0:
282 put_unaligned(0, &target[j]); 283 put_unaligned(0, &target[j]);
@@ -316,16 +317,13 @@ cifsConvertToUCS(__le16 *target, const char *source, int srclen,
316 dst_char = cpu_to_le16(0x003f); 317 dst_char = cpu_to_le16(0x003f);
317 charlen = 1; 318 charlen = 1;
318 } 319 }
319 /*
320 * character may take more than one byte in the source
321 * string, but will take exactly two bytes in the
322 * target string
323 */
324 i += charlen;
325 continue;
326 } 320 }
321 /*
322 * character may take more than one byte in the source string,
323 * but will take exactly two bytes in the target string
324 */
325 i += charlen;
327 put_unaligned(dst_char, &target[j]); 326 put_unaligned(dst_char, &target[j]);
328 i++; /* move to next char in source string */
329 } 327 }
330 328
331ctoUCS_out: 329ctoUCS_out: