diff options
Diffstat (limited to 'fs/cifs/cifsencrypt.c')
-rw-r--r-- | fs/cifs/cifsencrypt.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 5d9b9acc5fce..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; |
@@ -420,15 +420,20 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, | |||
420 | } | 420 | } |
421 | 421 | ||
422 | /* convert ses->user_name to unicode and uppercase */ | 422 | /* convert ses->user_name to unicode and uppercase */ |
423 | len = strlen(ses->user_name); | 423 | len = ses->user_name ? strlen(ses->user_name) : 0; |
424 | user = kmalloc(2 + (len * 2), GFP_KERNEL); | 424 | user = kmalloc(2 + (len * 2), GFP_KERNEL); |
425 | if (user == NULL) { | 425 | if (user == NULL) { |
426 | cERROR(1, "calc_ntlmv2_hash: user mem alloc failure\n"); | 426 | cERROR(1, "calc_ntlmv2_hash: user mem alloc failure\n"); |
427 | rc = -ENOMEM; | 427 | rc = -ENOMEM; |
428 | return rc; | 428 | return rc; |
429 | } | 429 | } |
430 | len = cifs_strtoUCS((__le16 *)user, ses->user_name, len, nls_cp); | 430 | |
431 | UniStrupr(user); | 431 | if (len) { |
432 | len = cifs_strtoUTF16((__le16 *)user, ses->user_name, len, nls_cp); | ||
433 | UniStrupr(user); | ||
434 | } else { | ||
435 | memset(user, '\0', 2); | ||
436 | } | ||
432 | 437 | ||
433 | rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, | 438 | rc = crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, |
434 | (char *)user, 2 * len); | 439 | (char *)user, 2 * len); |
@@ -448,8 +453,8 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, | |||
448 | rc = -ENOMEM; | 453 | rc = -ENOMEM; |
449 | return rc; | 454 | return rc; |
450 | } | 455 | } |
451 | len = cifs_strtoUCS((__le16 *)domain, ses->domainName, len, | 456 | len = cifs_strtoUTF16((__le16 *)domain, ses->domainName, len, |
452 | nls_cp); | 457 | nls_cp); |
453 | rc = | 458 | rc = |
454 | crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, | 459 | crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, |
455 | (char *)domain, 2 * len); | 460 | (char *)domain, 2 * len); |
@@ -468,7 +473,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash, | |||
468 | rc = -ENOMEM; | 473 | rc = -ENOMEM; |
469 | return rc; | 474 | return rc; |
470 | } | 475 | } |
471 | len = cifs_strtoUCS((__le16 *)server, ses->serverName, len, | 476 | len = cifs_strtoUTF16((__le16 *)server, ses->serverName, len, |
472 | nls_cp); | 477 | nls_cp); |
473 | rc = | 478 | rc = |
474 | crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, | 479 | crypto_shash_update(&ses->server->secmech.sdeschmacmd5->shash, |