Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Jeff Layton and committed by
Steve French
11379b5e 221d1d79

+6 -8
+6 -8
fs/cifs/cifs_unicode.c
··· 277 277 278 278 for (i = 0, j = 0; i < srclen; j++) { 279 279 src_char = source[i]; 280 + charlen = 1; 280 281 switch (src_char) { 281 282 case 0: 282 283 put_unaligned(0, &target[j]); ··· 317 316 dst_char = cpu_to_le16(0x003f); 318 317 charlen = 1; 319 318 } 320 - /* 321 - * character may take more than one byte in the source 322 - * string, but will take exactly two bytes in the 323 - * target string 324 - */ 325 - i += charlen; 326 - continue; 327 319 } 320 + /* 321 + * character may take more than one byte in the source string, 322 + * but will take exactly two bytes in the target string 323 + */ 324 + i += charlen; 328 325 put_unaligned(dst_char, &target[j]); 329 - i++; /* move to next char in source string */ 330 326 } 331 327 332 328 ctoUCS_out: