aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifs_unicode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/cifs_unicode.c')
-rw-r--r--fs/cifs/cifs_unicode.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index 5a53ac6b1e02..02b071bf3732 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -101,6 +101,12 @@ convert_sfm_char(const __u16 src_char, char *target)
101 case SFM_SLASH: 101 case SFM_SLASH:
102 *target = '\\'; 102 *target = '\\';
103 break; 103 break;
104 case SFM_SPACE:
105 *target = ' ';
106 break;
107 case SFM_PERIOD:
108 *target = '.';
109 break;
104 default: 110 default:
105 return false; 111 return false;
106 } 112 }
@@ -404,7 +410,7 @@ static __le16 convert_to_sfu_char(char src_char)
404 return dest_char; 410 return dest_char;
405} 411}
406 412
407static __le16 convert_to_sfm_char(char src_char) 413static __le16 convert_to_sfm_char(char src_char, bool end_of_string)
408{ 414{
409 __le16 dest_char; 415 __le16 dest_char;
410 416
@@ -427,6 +433,18 @@ static __le16 convert_to_sfm_char(char src_char)
427 case '|': 433 case '|':
428 dest_char = cpu_to_le16(SFM_PIPE); 434 dest_char = cpu_to_le16(SFM_PIPE);
429 break; 435 break;
436 case '.':
437 if (end_of_string)
438 dest_char = cpu_to_le16(SFM_PERIOD);
439 else
440 dest_char = 0;
441 break;
442 case ' ':
443 if (end_of_string)
444 dest_char = cpu_to_le16(SFM_SPACE);
445 else
446 dest_char = 0;
447 break;
430 default: 448 default:
431 dest_char = 0; 449 dest_char = 0;
432 } 450 }
@@ -469,9 +487,16 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
469 /* see if we must remap this char */ 487 /* see if we must remap this char */
470 if (map_chars == SFU_MAP_UNI_RSVD) 488 if (map_chars == SFU_MAP_UNI_RSVD)
471 dst_char = convert_to_sfu_char(src_char); 489 dst_char = convert_to_sfu_char(src_char);
472 else if (map_chars == SFM_MAP_UNI_RSVD) 490 else if (map_chars == SFM_MAP_UNI_RSVD) {
473 dst_char = convert_to_sfm_char(src_char); 491 bool end_of_string;
474 else 492
493 if (i == srclen - 1)
494 end_of_string = true;
495 else
496 end_of_string = false;
497
498 dst_char = convert_to_sfm_char(src_char, end_of_string);
499 } else
475 dst_char = 0; 500 dst_char = 0;
476 /* 501 /*
477 * FIXME: We can not handle remapping backslash (UNI_SLASH) 502 * FIXME: We can not handle remapping backslash (UNI_SLASH)