Commit acbbb76a26648dfae6fed0989879e40d75692bfc

Authored by Steve French
1 parent c56001879b

CIFS: Rename *UCS* functions to *UTF16*

to reflect the unicode encoding used by CIFS protocol.

Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Acked-by: Jeff Layton <jlayton@samba.org>
Reviewed-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>

Showing 8 changed files with 146 additions and 138 deletions Side-by-side Diff

fs/cifs/cifs_unicode.c
... ... @@ -27,17 +27,17 @@
27 27 #include "cifs_debug.h"
28 28  
29 29 /*
30   - * cifs_ucs2_bytes - how long will a string be after conversion?
31   - * @ucs - pointer to input string
  30 + * cifs_utf16_bytes - how long will a string be after conversion?
  31 + * @utf16 - pointer to input string
32 32 * @maxbytes - don't go past this many bytes of input string
33 33 * @codepage - destination codepage
34 34 *
35   - * Walk a ucs2le string and return the number of bytes that the string will
  35 + * Walk a utf16le string and return the number of bytes that the string will
36 36 * be after being converted to the given charset, not including any null
37 37 * termination required. Don't walk past maxbytes in the source buffer.
38 38 */
39 39 int
40   -cifs_ucs2_bytes(const __le16 *from, int maxbytes,
  40 +cifs_utf16_bytes(const __le16 *from, int maxbytes,
41 41 const struct nls_table *codepage)
42 42 {
43 43 int i;
... ... @@ -122,7 +122,7 @@
122 122 }
123 123  
124 124 /*
125   - * cifs_from_ucs2 - convert utf16le string to local charset
  125 + * cifs_from_utf16 - convert utf16le string to local charset
126 126 * @to - destination buffer
127 127 * @from - source buffer
128 128 * @tolen - destination buffer size (in bytes)
... ... @@ -130,7 +130,7 @@
130 130 * @codepage - codepage to which characters should be converted
131 131 * @mapchar - should characters be remapped according to the mapchars option?
132 132 *
133   - * Convert a little-endian ucs2le string (as sent by the server) to a string
  133 + * Convert a little-endian utf16le string (as sent by the server) to a string
134 134 * in the provided codepage. The tolen and fromlen parameters are to ensure
135 135 * that the code doesn't walk off of the end of the buffer (which is always
136 136 * a danger if the alignment of the source buffer is off). The destination
137 137  
... ... @@ -139,12 +139,12 @@
139 139 * null terminator).
140 140 *
141 141 * Note that some windows versions actually send multiword UTF-16 characters
142   - * instead of straight UCS-2. The linux nls routines however aren't able to
  142 + * instead of straight UTF16-2. The linux nls routines however aren't able to
143 143 * deal with those characters properly. In the event that we get some of
144 144 * those characters, they won't be translated properly.
145 145 */
146 146 int
147   -cifs_from_ucs2(char *to, const __le16 *from, int tolen, int fromlen,
  147 +cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen,
148 148 const struct nls_table *codepage, bool mapchar)
149 149 {
150 150 int i, charlen, safelen;
151 151  
... ... @@ -190,13 +190,13 @@
190 190 }
191 191  
192 192 /*
193   - * NAME: cifs_strtoUCS()
  193 + * NAME: cifs_strtoUTF16()
194 194 *
195 195 * FUNCTION: Convert character string to unicode string
196 196 *
197 197 */
198 198 int
199   -cifs_strtoUCS(__le16 *to, const char *from, int len,
  199 +cifs_strtoUTF16(__le16 *to, const char *from, int len,
200 200 const struct nls_table *codepage)
201 201 {
202 202 int charlen;
... ... @@ -206,7 +206,7 @@
206 206 for (i = 0; len && *from; i++, from += charlen, len -= charlen) {
207 207 charlen = codepage->char2uni(from, len, &wchar_to);
208 208 if (charlen < 1) {
209   - cERROR(1, "strtoUCS: char2uni of 0x%x returned %d",
  209 + cERROR(1, "strtoUTF16: char2uni of 0x%x returned %d",
210 210 *from, charlen);
211 211 /* A question mark */
212 212 wchar_to = 0x003f;
... ... @@ -220,7 +220,8 @@
220 220 }
221 221  
222 222 /*
223   - * cifs_strndup_from_ucs - copy a string from wire format to the local codepage
  223 + * cifs_strndup_from_utf16 - copy a string from wire format to the local
  224 + * codepage
224 225 * @src - source string
225 226 * @maxlen - don't walk past this many bytes in the source string
226 227 * @is_unicode - is this a unicode string?
227 228  
228 229  
... ... @@ -231,19 +232,19 @@
231 232 * error.
232 233 */
233 234 char *
234   -cifs_strndup_from_ucs(const char *src, const int maxlen, const bool is_unicode,
235   - const struct nls_table *codepage)
  235 +cifs_strndup_from_utf16(const char *src, const int maxlen,
  236 + const bool is_unicode, const struct nls_table *codepage)
236 237 {
237 238 int len;
238 239 char *dst;
239 240  
240 241 if (is_unicode) {
241   - len = cifs_ucs2_bytes((__le16 *) src, maxlen, codepage);
  242 + len = cifs_utf16_bytes((__le16 *) src, maxlen, codepage);
242 243 len += nls_nullsize(codepage);
243 244 dst = kmalloc(len, GFP_KERNEL);
244 245 if (!dst)
245 246 return NULL;
246   - cifs_from_ucs2(dst, (__le16 *) src, len, maxlen, codepage,
  247 + cifs_from_utf16(dst, (__le16 *) src, len, maxlen, codepage,
247 248 false);
248 249 } else {
249 250 len = strnlen(src, maxlen);
... ... @@ -264,7 +265,7 @@
264 265 * names are little endian 16 bit Unicode on the wire
265 266 */
266 267 int
267   -cifsConvertToUCS(__le16 *target, const char *source, int srclen,
  268 +cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
268 269 const struct nls_table *cp, int mapChars)
269 270 {
270 271 int i, j, charlen;
... ... @@ -273,7 +274,7 @@
273 274 wchar_t tmp;
274 275  
275 276 if (!mapChars)
276   - return cifs_strtoUCS(target, source, PATH_MAX, cp);
  277 + return cifs_strtoUTF16(target, source, PATH_MAX, cp);
277 278  
278 279 for (i = 0, j = 0; i < srclen; j++) {
279 280 src_char = source[i];
... ... @@ -281,7 +282,7 @@
281 282 switch (src_char) {
282 283 case 0:
283 284 put_unaligned(0, &target[j]);
284   - goto ctoUCS_out;
  285 + goto ctoUTF16_out;
285 286 case ':':
286 287 dst_char = cpu_to_le16(UNI_COLON);
287 288 break;
... ... @@ -326,7 +327,7 @@
326 327 put_unaligned(dst_char, &target[j]);
327 328 }
328 329  
329   -ctoUCS_out:
  330 +ctoUTF16_out:
330 331 return i;
331 332 }
fs/cifs/cifs_unicode.h
... ... @@ -74,16 +74,16 @@
74 74 #endif /* UNIUPR_NOLOWER */
75 75  
76 76 #ifdef __KERNEL__
77   -int cifs_from_ucs2(char *to, const __le16 *from, int tolen, int fromlen,
78   - const struct nls_table *codepage, bool mapchar);
79   -int cifs_ucs2_bytes(const __le16 *from, int maxbytes,
80   - const struct nls_table *codepage);
81   -int cifs_strtoUCS(__le16 *, const char *, int, const struct nls_table *);
82   -char *cifs_strndup_from_ucs(const char *src, const int maxlen,
83   - const bool is_unicode,
84   - const struct nls_table *codepage);
85   -extern int cifsConvertToUCS(__le16 *target, const char *source, int maxlen,
86   - const struct nls_table *cp, int mapChars);
  77 +int cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen,
  78 + const struct nls_table *codepage, bool mapchar);
  79 +int cifs_utf16_bytes(const __le16 *from, int maxbytes,
  80 + const struct nls_table *codepage);
  81 +int cifs_strtoUTF16(__le16 *, const char *, int, const struct nls_table *);
  82 +char *cifs_strndup_from_utf16(const char *src, const int maxlen,
  83 + const bool is_unicode,
  84 + const struct nls_table *codepage);
  85 +extern int cifsConvertToUTF16(__le16 *target, const char *source, int maxlen,
  86 + const struct nls_table *cp, int mapChars);
87 87  
88 88 #endif
89 89  
fs/cifs/cifsencrypt.c
... ... @@ -327,7 +327,7 @@
327 327 attrptr->type = cpu_to_le16(NTLMSSP_AV_NB_DOMAIN_NAME);
328 328 attrptr->length = cpu_to_le16(2 * dlen);
329 329 blobptr = (unsigned char *)attrptr + sizeof(struct ntlmssp2_name);
330   - cifs_strtoUCS((__le16 *)blobptr, ses->domainName, dlen, nls_cp);
  330 + cifs_strtoUTF16((__le16 *)blobptr, ses->domainName, dlen, nls_cp);
331 331  
332 332 return 0;
333 333 }
... ... @@ -376,7 +376,7 @@
376 376 kmalloc(attrsize + 1, GFP_KERNEL);
377 377 if (!ses->domainName)
378 378 return -ENOMEM;
379   - cifs_from_ucs2(ses->domainName,
  379 + cifs_from_utf16(ses->domainName,
380 380 (__le16 *)blobptr, attrsize, attrsize,
381 381 nls_cp, false);
382 382 break;
... ... @@ -429,7 +429,7 @@
429 429 }
430 430  
431 431 if (len) {
432   - len = cifs_strtoUCS((__le16 *)user, ses->user_name, len, nls_cp);
  432 + len = cifs_strtoUTF16((__le16 *)user, ses->user_name, len, nls_cp);
433 433 UniStrupr(user);
434 434 } else {
435 435 memset(user, '\0', 2);
... ... @@ -453,8 +453,8 @@
453 453 rc = -ENOMEM;
454 454 return rc;
455 455 }
456   - len = cifs_strtoUCS((__le16 *)domain, ses->domainName, len,
457   - nls_cp);
  456 + len = cifs_strtoUTF16((__le16 *)domain, ses->domainName, len,
  457 + nls_cp);
458 458 rc =
459 459 crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
460 460 (char *)domain, 2 * len);
... ... @@ -473,7 +473,7 @@
473 473 rc = -ENOMEM;
474 474 return rc;
475 475 }
476   - len = cifs_strtoUCS((__le16 *)server, ses->serverName, len,
  476 + len = cifs_strtoUTF16((__le16 *)server, ses->serverName, len,
477 477 nls_cp);
478 478 rc =
479 479 crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash,
... ... @@ -821,8 +821,8 @@
821 821  
822 822 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
823 823 name_len =
824   - cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
825   - PATH_MAX, nls_codepage, remap);
  824 + cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName,
  825 + PATH_MAX, nls_codepage, remap);
826 826 name_len++; /* trailing null */
827 827 name_len *= 2;
828 828 } else { /* BB add path length overrun check */
... ... @@ -893,8 +893,8 @@
893 893  
894 894 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
895 895 name_len =
896   - cifsConvertToUCS((__le16 *) pSMB->fileName, fileName,
897   - PATH_MAX, nls_codepage, remap);
  896 + cifsConvertToUTF16((__le16 *) pSMB->fileName, fileName,
  897 + PATH_MAX, nls_codepage, remap);
898 898 name_len++; /* trailing null */
899 899 name_len *= 2;
900 900 } else { /* BB improve check for buffer overruns BB */
... ... @@ -938,8 +938,8 @@
938 938 return rc;
939 939  
940 940 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
941   - name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, dirName,
942   - PATH_MAX, nls_codepage, remap);
  941 + name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, dirName,
  942 + PATH_MAX, nls_codepage, remap);
943 943 name_len++; /* trailing null */
944 944 name_len *= 2;
945 945 } else { /* BB improve check for buffer overruns BB */
... ... @@ -981,8 +981,8 @@
981 981 return rc;
982 982  
983 983 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
984   - name_len = cifsConvertToUCS((__le16 *) pSMB->DirName, name,
985   - PATH_MAX, nls_codepage, remap);
  984 + name_len = cifsConvertToUTF16((__le16 *) pSMB->DirName, name,
  985 + PATH_MAX, nls_codepage, remap);
986 986 name_len++; /* trailing null */
987 987 name_len *= 2;
988 988 } else { /* BB improve check for buffer overruns BB */
... ... @@ -1030,8 +1030,8 @@
1030 1030  
1031 1031 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1032 1032 name_len =
1033   - cifsConvertToUCS((__le16 *) pSMB->FileName, name,
1034   - PATH_MAX, nls_codepage, remap);
  1033 + cifsConvertToUTF16((__le16 *) pSMB->FileName, name,
  1034 + PATH_MAX, nls_codepage, remap);
1035 1035 name_len++; /* trailing null */
1036 1036 name_len *= 2;
1037 1037 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -1197,8 +1197,8 @@
1197 1197 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1198 1198 count = 1; /* account for one byte pad to word boundary */
1199 1199 name_len =
1200   - cifsConvertToUCS((__le16 *) (pSMB->fileName + 1),
1201   - fileName, PATH_MAX, nls_codepage, remap);
  1200 + cifsConvertToUTF16((__le16 *) (pSMB->fileName + 1),
  1201 + fileName, PATH_MAX, nls_codepage, remap);
1202 1202 name_len++; /* trailing null */
1203 1203 name_len *= 2;
1204 1204 } else { /* BB improve check for buffer overruns BB */
... ... @@ -1304,8 +1304,8 @@
1304 1304 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
1305 1305 count = 1; /* account for one byte pad to word boundary */
1306 1306 name_len =
1307   - cifsConvertToUCS((__le16 *) (pSMB->fileName + 1),
1308   - fileName, PATH_MAX, nls_codepage, remap);
  1307 + cifsConvertToUTF16((__le16 *) (pSMB->fileName + 1),
  1308 + fileName, PATH_MAX, nls_codepage, remap);
1309 1309 name_len++; /* trailing null */
1310 1310 name_len *= 2;
1311 1311 pSMB->NameLength = cpu_to_le16(name_len);
1312 1312  
... ... @@ -2649,16 +2649,16 @@
2649 2649  
2650 2650 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2651 2651 name_len =
2652   - cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName,
2653   - PATH_MAX, nls_codepage, remap);
  2652 + cifsConvertToUTF16((__le16 *) pSMB->OldFileName, fromName,
  2653 + PATH_MAX, nls_codepage, remap);
2654 2654 name_len++; /* trailing null */
2655 2655 name_len *= 2;
2656 2656 pSMB->OldFileName[name_len] = 0x04; /* pad */
2657 2657 /* protocol requires ASCII signature byte on Unicode string */
2658 2658 pSMB->OldFileName[name_len + 1] = 0x00;
2659 2659 name_len2 =
2660   - cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2],
2661   - toName, PATH_MAX, nls_codepage, remap);
  2660 + cifsConvertToUTF16((__le16 *)&pSMB->OldFileName[name_len+2],
  2661 + toName, PATH_MAX, nls_codepage, remap);
2662 2662 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
2663 2663 name_len2 *= 2; /* convert to bytes */
2664 2664 } else { /* BB improve the check for buffer overruns BB */
2665 2665  
... ... @@ -2738,10 +2738,12 @@
2738 2738 /* unicode only call */
2739 2739 if (target_name == NULL) {
2740 2740 sprintf(dummy_string, "cifs%x", pSMB->hdr.Mid);
2741   - len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name,
  2741 + len_of_str =
  2742 + cifsConvertToUTF16((__le16 *)rename_info->target_name,
2742 2743 dummy_string, 24, nls_codepage, remap);
2743 2744 } else {
2744   - len_of_str = cifsConvertToUCS((__le16 *)rename_info->target_name,
  2745 + len_of_str =
  2746 + cifsConvertToUTF16((__le16 *)rename_info->target_name,
2745 2747 target_name, PATH_MAX, nls_codepage,
2746 2748 remap);
2747 2749 }
2748 2750  
... ... @@ -2795,17 +2797,17 @@
2795 2797 pSMB->Flags = cpu_to_le16(flags & COPY_TREE);
2796 2798  
2797 2799 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2798   - name_len = cifsConvertToUCS((__le16 *) pSMB->OldFileName,
2799   - fromName, PATH_MAX, nls_codepage,
2800   - remap);
  2800 + name_len = cifsConvertToUTF16((__le16 *) pSMB->OldFileName,
  2801 + fromName, PATH_MAX, nls_codepage,
  2802 + remap);
2801 2803 name_len++; /* trailing null */
2802 2804 name_len *= 2;
2803 2805 pSMB->OldFileName[name_len] = 0x04; /* pad */
2804 2806 /* protocol requires ASCII signature byte on Unicode string */
2805 2807 pSMB->OldFileName[name_len + 1] = 0x00;
2806 2808 name_len2 =
2807   - cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2],
2808   - toName, PATH_MAX, nls_codepage, remap);
  2809 + cifsConvertToUTF16((__le16 *)&pSMB->OldFileName[name_len+2],
  2810 + toName, PATH_MAX, nls_codepage, remap);
2809 2811 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
2810 2812 name_len2 *= 2; /* convert to bytes */
2811 2813 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -2861,9 +2863,9 @@
2861 2863  
2862 2864 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2863 2865 name_len =
2864   - cifs_strtoUCS((__le16 *) pSMB->FileName, fromName, PATH_MAX
2865   - /* find define for this maxpathcomponent */
2866   - , nls_codepage);
  2866 + cifs_strtoUTF16((__le16 *) pSMB->FileName, fromName,
  2867 + /* find define for this maxpathcomponent */
  2868 + PATH_MAX, nls_codepage);
2867 2869 name_len++; /* trailing null */
2868 2870 name_len *= 2;
2869 2871  
... ... @@ -2885,9 +2887,9 @@
2885 2887 data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
2886 2888 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2887 2889 name_len_target =
2888   - cifs_strtoUCS((__le16 *) data_offset, toName, PATH_MAX
2889   - /* find define for this maxpathcomponent */
2890   - , nls_codepage);
  2890 + cifs_strtoUTF16((__le16 *) data_offset, toName, PATH_MAX
  2891 + /* find define for this maxpathcomponent */
  2892 + , nls_codepage);
2891 2893 name_len_target++; /* trailing null */
2892 2894 name_len_target *= 2;
2893 2895 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -2949,8 +2951,8 @@
2949 2951 return rc;
2950 2952  
2951 2953 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2952   - name_len = cifsConvertToUCS((__le16 *) pSMB->FileName, toName,
2953   - PATH_MAX, nls_codepage, remap);
  2954 + name_len = cifsConvertToUTF16((__le16 *) pSMB->FileName, toName,
  2955 + PATH_MAX, nls_codepage, remap);
2954 2956 name_len++; /* trailing null */
2955 2957 name_len *= 2;
2956 2958  
... ... @@ -2972,8 +2974,8 @@
2972 2974 data_offset = (char *) (&pSMB->hdr.Protocol) + offset;
2973 2975 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
2974 2976 name_len_target =
2975   - cifsConvertToUCS((__le16 *) data_offset, fromName, PATH_MAX,
2976   - nls_codepage, remap);
  2977 + cifsConvertToUTF16((__le16 *) data_offset, fromName,
  2978 + PATH_MAX, nls_codepage, remap);
2977 2979 name_len_target++; /* trailing null */
2978 2980 name_len_target *= 2;
2979 2981 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -3042,8 +3044,8 @@
3042 3044  
3043 3045 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3044 3046 name_len =
3045   - cifsConvertToUCS((__le16 *) pSMB->OldFileName, fromName,
3046   - PATH_MAX, nls_codepage, remap);
  3047 + cifsConvertToUTF16((__le16 *) pSMB->OldFileName, fromName,
  3048 + PATH_MAX, nls_codepage, remap);
3047 3049 name_len++; /* trailing null */
3048 3050 name_len *= 2;
3049 3051  
... ... @@ -3051,8 +3053,8 @@
3051 3053 pSMB->OldFileName[name_len] = 0x04;
3052 3054 pSMB->OldFileName[name_len + 1] = 0x00; /* pad */
3053 3055 name_len2 =
3054   - cifsConvertToUCS((__le16 *)&pSMB->OldFileName[name_len + 2],
3055   - toName, PATH_MAX, nls_codepage, remap);
  3056 + cifsConvertToUTF16((__le16 *)&pSMB->OldFileName[name_len+2],
  3057 + toName, PATH_MAX, nls_codepage, remap);
3056 3058 name_len2 += 1 /* trailing null */ + 1 /* Signature word */ ;
3057 3059 name_len2 *= 2; /* convert to bytes */
3058 3060 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -3108,8 +3110,8 @@
3108 3110  
3109 3111 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3110 3112 name_len =
3111   - cifs_strtoUCS((__le16 *) pSMB->FileName, searchName,
3112   - PATH_MAX, nls_codepage);
  3113 + cifs_strtoUTF16((__le16 *) pSMB->FileName, searchName,
  3114 + PATH_MAX, nls_codepage);
3113 3115 name_len++; /* trailing null */
3114 3116 name_len *= 2;
3115 3117 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -3166,8 +3168,8 @@
3166 3168 is_unicode = false;
3167 3169  
3168 3170 /* BB FIXME investigate remapping reserved chars here */
3169   - *symlinkinfo = cifs_strndup_from_ucs(data_start, count,
3170   - is_unicode, nls_codepage);
  3171 + *symlinkinfo = cifs_strndup_from_utf16(data_start,
  3172 + count, is_unicode, nls_codepage);
3171 3173 if (!*symlinkinfo)
3172 3174 rc = -ENOMEM;
3173 3175 }
... ... @@ -3450,8 +3452,9 @@
3450 3452  
3451 3453 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3452 3454 name_len =
3453   - cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
3454   - PATH_MAX, nls_codepage, remap);
  3455 + cifsConvertToUTF16((__le16 *) pSMB->FileName,
  3456 + searchName, PATH_MAX, nls_codepage,
  3457 + remap);
3455 3458 name_len++; /* trailing null */
3456 3459 name_len *= 2;
3457 3460 pSMB->FileName[name_len] = 0;
... ... @@ -3537,8 +3540,8 @@
3537 3540 return rc;
3538 3541 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3539 3542 name_len =
3540   - cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
3541   - PATH_MAX, nls_codepage, remap);
  3543 + cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName,
  3544 + PATH_MAX, nls_codepage, remap);
3542 3545 name_len++; /* trailing null */
3543 3546 name_len *= 2;
3544 3547 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -3948,8 +3951,9 @@
3948 3951  
3949 3952 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
3950 3953 name_len =
3951   - cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
3952   - PATH_MAX, nls_codepage, remap);
  3954 + cifsConvertToUTF16((__le16 *) pSMB->FileName,
  3955 + searchName, PATH_MAX, nls_codepage,
  3956 + remap);
3953 3957 name_len++; /* trailing null */
3954 3958 name_len *= 2;
3955 3959 } else {
... ... @@ -4086,8 +4090,8 @@
4086 4090  
4087 4091 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
4088 4092 name_len =
4089   - cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
4090   - PATH_MAX, nls_codepage, remap);
  4093 + cifsConvertToUTF16((__le16 *) pSMB->FileName, searchName,
  4094 + PATH_MAX, nls_codepage, remap);
4091 4095 name_len++; /* trailing null */
4092 4096 name_len *= 2;
4093 4097 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -4255,8 +4259,8 @@
4255 4259  
4256 4260 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
4257 4261 name_len =
4258   - cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
4259   - PATH_MAX, nls_codepage, remap);
  4262 + cifsConvertToUTF16((__le16 *) pSMB->FileName, searchName,
  4263 + PATH_MAX, nls_codepage, remap);
4260 4264 name_len++; /* trailing null */
4261 4265 name_len *= 2;
4262 4266 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -4344,8 +4348,8 @@
4344 4348  
4345 4349 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
4346 4350 name_len =
4347   - cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
4348   - PATH_MAX, nls_codepage, remap);
  4351 + cifsConvertToUTF16((__le16 *) pSMB->FileName, searchName,
  4352 + PATH_MAX, nls_codepage, remap);
4349 4353 /* We can not add the asterik earlier in case
4350 4354 it got remapped to 0xF03A as if it were part of the
4351 4355 directory name instead of a wildcard */
... ... @@ -4656,8 +4660,9 @@
4656 4660  
4657 4661 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
4658 4662 name_len =
4659   - cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
4660   - PATH_MAX, nls_codepage, remap);
  4663 + cifsConvertToUTF16((__le16 *) pSMB->FileName,
  4664 + searchName, PATH_MAX, nls_codepage,
  4665 + remap);
4661 4666 name_len++; /* trailing null */
4662 4667 name_len *= 2;
4663 4668 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -4794,9 +4799,9 @@
4794 4799 rc = -ENOMEM;
4795 4800 goto parse_DFS_referrals_exit;
4796 4801 }
4797   - cifsConvertToUCS((__le16 *) tmp, searchName,
4798   - PATH_MAX, nls_codepage, remap);
4799   - node->path_consumed = cifs_ucs2_bytes(tmp,
  4802 + cifsConvertToUTF16((__le16 *) tmp, searchName,
  4803 + PATH_MAX, nls_codepage, remap);
  4804 + node->path_consumed = cifs_utf16_bytes(tmp,
4800 4805 le16_to_cpu(pSMBr->PathConsumed),
4801 4806 nls_codepage);
4802 4807 kfree(tmp);
... ... @@ -4809,8 +4814,8 @@
4809 4814 /* copy DfsPath */
4810 4815 temp = (char *)ref + le16_to_cpu(ref->DfsPathOffset);
4811 4816 max_len = data_end - temp;
4812   - node->path_name = cifs_strndup_from_ucs(temp, max_len,
4813   - is_unicode, nls_codepage);
  4817 + node->path_name = cifs_strndup_from_utf16(temp, max_len,
  4818 + is_unicode, nls_codepage);
4814 4819 if (!node->path_name) {
4815 4820 rc = -ENOMEM;
4816 4821 goto parse_DFS_referrals_exit;
... ... @@ -4819,8 +4824,8 @@
4819 4824 /* copy link target UNC */
4820 4825 temp = (char *)ref + le16_to_cpu(ref->NetworkAddressOffset);
4821 4826 max_len = data_end - temp;
4822   - node->node_name = cifs_strndup_from_ucs(temp, max_len,
4823   - is_unicode, nls_codepage);
  4827 + node->node_name = cifs_strndup_from_utf16(temp, max_len,
  4828 + is_unicode, nls_codepage);
4824 4829 if (!node->node_name)
4825 4830 rc = -ENOMEM;
4826 4831 }
... ... @@ -4873,8 +4878,9 @@
4873 4878 if (ses->capabilities & CAP_UNICODE) {
4874 4879 pSMB->hdr.Flags2 |= SMBFLG2_UNICODE;
4875 4880 name_len =
4876   - cifsConvertToUCS((__le16 *) pSMB->RequestFileName,
4877   - searchName, PATH_MAX, nls_codepage, remap);
  4881 + cifsConvertToUTF16((__le16 *) pSMB->RequestFileName,
  4882 + searchName, PATH_MAX, nls_codepage,
  4883 + remap);
4878 4884 name_len++; /* trailing null */
4879 4885 name_len *= 2;
4880 4886 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -5506,8 +5512,8 @@
5506 5512  
5507 5513 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
5508 5514 name_len =
5509   - cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
5510   - PATH_MAX, nls_codepage, remap);
  5515 + cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName,
  5516 + PATH_MAX, nls_codepage, remap);
5511 5517 name_len++; /* trailing null */
5512 5518 name_len *= 2;
5513 5519 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -5796,8 +5802,8 @@
5796 5802  
5797 5803 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
5798 5804 name_len =
5799   - cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
5800   - PATH_MAX, nls_codepage, remap);
  5805 + cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName,
  5806 + PATH_MAX, nls_codepage, remap);
5801 5807 name_len++; /* trailing null */
5802 5808 name_len *= 2;
5803 5809 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -5877,8 +5883,8 @@
5877 5883  
5878 5884 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
5879 5885 name_len =
5880   - ConvertToUCS((__le16 *) pSMB->fileName, fileName,
5881   - PATH_MAX, nls_codepage);
  5886 + ConvertToUTF16((__le16 *) pSMB->fileName, fileName,
  5887 + PATH_MAX, nls_codepage);
5882 5888 name_len++; /* trailing null */
5883 5889 name_len *= 2;
5884 5890 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -6030,8 +6036,8 @@
6030 6036  
6031 6037 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
6032 6038 name_len =
6033   - cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
6034   - PATH_MAX, nls_codepage, remap);
  6039 + cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName,
  6040 + PATH_MAX, nls_codepage, remap);
6035 6041 name_len++; /* trailing null */
6036 6042 name_len *= 2;
6037 6043 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -6123,8 +6129,8 @@
6123 6129  
6124 6130 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
6125 6131 list_len =
6126   - cifsConvertToUCS((__le16 *) pSMB->FileName, searchName,
6127   - PATH_MAX, nls_codepage, remap);
  6132 + cifsConvertToUTF16((__le16 *) pSMB->FileName, searchName,
  6133 + PATH_MAX, nls_codepage, remap);
6128 6134 list_len++; /* trailing null */
6129 6135 list_len *= 2;
6130 6136 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -6301,8 +6307,8 @@
6301 6307  
6302 6308 if (pSMB->hdr.Flags2 & SMBFLG2_UNICODE) {
6303 6309 name_len =
6304   - cifsConvertToUCS((__le16 *) pSMB->FileName, fileName,
6305   - PATH_MAX, nls_codepage, remap);
  6310 + cifsConvertToUTF16((__le16 *) pSMB->FileName, fileName,
  6311 + PATH_MAX, nls_codepage, remap);
6306 6312 name_len++; /* trailing null */
6307 6313 name_len *= 2;
6308 6314 } else { /* BB improve the check for buffer overruns BB */
... ... @@ -3644,7 +3644,7 @@
3644 3644 if (ses->capabilities & CAP_UNICODE) {
3645 3645 smb_buffer->Flags2 |= SMBFLG2_UNICODE;
3646 3646 length =
3647   - cifs_strtoUCS((__le16 *) bcc_ptr, tree,
  3647 + cifs_strtoUTF16((__le16 *) bcc_ptr, tree,
3648 3648 6 /* max utf8 char length in bytes */ *
3649 3649 (/* server len*/ + 256 /* share len */), nls_codepage);
3650 3650 bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */
... ... @@ -3699,7 +3699,7 @@
3699 3699  
3700 3700 /* mostly informational -- no need to fail on error here */
3701 3701 kfree(tcon->nativeFileSystem);
3702   - tcon->nativeFileSystem = cifs_strndup_from_ucs(bcc_ptr,
  3702 + tcon->nativeFileSystem = cifs_strndup_from_utf16(bcc_ptr,
3703 3703 bytes_left, is_unicode,
3704 3704 nls_codepage);
3705 3705  
... ... @@ -647,10 +647,11 @@
647 647  
648 648 name.name = scratch_buf;
649 649 name.len =
650   - cifs_from_ucs2((char *)name.name, (__le16 *)de.name,
651   - UNICODE_NAME_MAX,
652   - min(de.namelen, (size_t)max_len), nlt,
653   - cifs_sb->mnt_cifs_flags &
  650 + cifs_from_utf16((char *)name.name, (__le16 *)de.name,
  651 + UNICODE_NAME_MAX,
  652 + min_t(size_t, de.namelen,
  653 + (size_t)max_len), nlt,
  654 + cifs_sb->mnt_cifs_flags &
654 655 CIFS_MOUNT_MAP_SPECIAL_CHR);
655 656 name.len -= nls_nullsize(nlt);
656 657 } else {
... ... @@ -167,16 +167,16 @@
167 167 int bytes_ret = 0;
168 168  
169 169 /* Copy OS version */
170   - bytes_ret = cifs_strtoUCS((__le16 *)bcc_ptr, "Linux version ", 32,
171   - nls_cp);
  170 + bytes_ret = cifs_strtoUTF16((__le16 *)bcc_ptr, "Linux version ", 32,
  171 + nls_cp);
172 172 bcc_ptr += 2 * bytes_ret;
173   - bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, init_utsname()->release,
174   - 32, nls_cp);
  173 + bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, init_utsname()->release,
  174 + 32, nls_cp);
175 175 bcc_ptr += 2 * bytes_ret;
176 176 bcc_ptr += 2; /* trailing null */
177 177  
178   - bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
179   - 32, nls_cp);
  178 + bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
  179 + 32, nls_cp);
180 180 bcc_ptr += 2 * bytes_ret;
181 181 bcc_ptr += 2; /* trailing null */
182 182  
... ... @@ -197,8 +197,8 @@
197 197 *(bcc_ptr+1) = 0;
198 198 bytes_ret = 0;
199 199 } else
200   - bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->domainName,
201   - 256, nls_cp);
  200 + bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName,
  201 + 256, nls_cp);
202 202 bcc_ptr += 2 * bytes_ret;
203 203 bcc_ptr += 2; /* account for null terminator */
204 204  
... ... @@ -226,8 +226,8 @@
226 226 *bcc_ptr = 0;
227 227 *(bcc_ptr+1) = 0;
228 228 } else {
229   - bytes_ret = cifs_strtoUCS((__le16 *) bcc_ptr, ses->user_name,
230   - MAX_USERNAME_SIZE, nls_cp);
  229 + bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name,
  230 + MAX_USERNAME_SIZE, nls_cp);
231 231 }
232 232 bcc_ptr += 2 * bytes_ret;
233 233 bcc_ptr += 2; /* account for null termination */
... ... @@ -287,7 +287,7 @@
287 287 cFYI(1, "bleft %d", bleft);
288 288  
289 289 kfree(ses->serverOS);
290   - ses->serverOS = cifs_strndup_from_ucs(data, bleft, true, nls_cp);
  290 + ses->serverOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp);
291 291 cFYI(1, "serverOS=%s", ses->serverOS);
292 292 len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
293 293 data += len;
... ... @@ -296,7 +296,7 @@
296 296 return;
297 297  
298 298 kfree(ses->serverNOS);
299   - ses->serverNOS = cifs_strndup_from_ucs(data, bleft, true, nls_cp);
  299 + ses->serverNOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp);
300 300 cFYI(1, "serverNOS=%s", ses->serverNOS);
301 301 len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
302 302 data += len;
... ... @@ -305,7 +305,7 @@
305 305 return;
306 306  
307 307 kfree(ses->serverDomain);
308   - ses->serverDomain = cifs_strndup_from_ucs(data, bleft, true, nls_cp);
  308 + ses->serverDomain = cifs_strndup_from_utf16(data, bleft, true, nls_cp);
309 309 cFYI(1, "serverDomain=%s", ses->serverDomain);
310 310  
311 311 return;
... ... @@ -502,8 +502,8 @@
502 502 tmp += 2;
503 503 } else {
504 504 int len;
505   - len = cifs_strtoUCS((__le16 *)tmp, ses->domainName,
506   - MAX_USERNAME_SIZE, nls_cp);
  505 + len = cifs_strtoUTF16((__le16 *)tmp, ses->domainName,
  506 + MAX_USERNAME_SIZE, nls_cp);
507 507 len *= 2; /* unicode is 2 bytes each */
508 508 sec_blob->DomainName.BufferOffset = cpu_to_le32(tmp - pbuffer);
509 509 sec_blob->DomainName.Length = cpu_to_le16(len);
... ... @@ -518,8 +518,8 @@
518 518 tmp += 2;
519 519 } else {
520 520 int len;
521   - len = cifs_strtoUCS((__le16 *)tmp, ses->user_name,
522   - MAX_USERNAME_SIZE, nls_cp);
  521 + len = cifs_strtoUTF16((__le16 *)tmp, ses->user_name,
  522 + MAX_USERNAME_SIZE, nls_cp);
523 523 len *= 2; /* unicode is 2 bytes each */
524 524 sec_blob->UserName.BufferOffset = cpu_to_le32(tmp - pbuffer);
525 525 sec_blob->UserName.Length = cpu_to_le16(len);
fs/cifs/smbencrypt.c
... ... @@ -213,7 +213,7 @@
213 213  
214 214 /* Password cannot be longer than 128 characters */
215 215 if (passwd) /* Password must be converted to NT unicode */
216   - len = cifs_strtoUCS(wpwd, passwd, 128, codepage);
  216 + len = cifs_strtoUTF16(wpwd, passwd, 128, codepage);
217 217 else {
218 218 len = 0;
219 219 *wpwd = 0; /* Ensure string is null terminated */