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