aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifsencrypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/cifsencrypt.c')
-rw-r--r--fs/cifs/cifsencrypt.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index 96908874a45c..17d603ad5e34 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -391,7 +391,7 @@ build_avpair_blob(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
391 * about target string i.e. for some, just user name might suffice. 391 * about target string i.e. for some, just user name might suffice.
392 */ 392 */
393static int 393static int
394find_domain_name(struct cifsSesInfo *ses) 394find_domain_name(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
395{ 395{
396 unsigned int attrsize; 396 unsigned int attrsize;
397 unsigned int type; 397 unsigned int type;
@@ -420,16 +420,13 @@ find_domain_name(struct cifsSesInfo *ses)
420 if (!attrsize) 420 if (!attrsize)
421 break; 421 break;
422 if (!ses->domainName) { 422 if (!ses->domainName) {
423 struct nls_table *default_nls;
424 ses->domainName = 423 ses->domainName =
425 kmalloc(attrsize + 1, GFP_KERNEL); 424 kmalloc(attrsize + 1, GFP_KERNEL);
426 if (!ses->domainName) 425 if (!ses->domainName)
427 return -ENOMEM; 426 return -ENOMEM;
428 default_nls = load_nls_default();
429 cifs_from_ucs2(ses->domainName, 427 cifs_from_ucs2(ses->domainName,
430 (__le16 *)blobptr, attrsize, attrsize, 428 (__le16 *)blobptr, attrsize, attrsize,
431 default_nls, false); 429 nls_cp, false);
432 unload_nls(default_nls);
433 break; 430 break;
434 } 431 }
435 } 432 }
@@ -561,7 +558,7 @@ setup_ntlmv2_rsp(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
561 558
562 if (ses->server->secType == RawNTLMSSP) { 559 if (ses->server->secType == RawNTLMSSP) {
563 if (!ses->domainName) { 560 if (!ses->domainName) {
564 rc = find_domain_name(ses); 561 rc = find_domain_name(ses, nls_cp);
565 if (rc) { 562 if (rc) {
566 cERROR(1, "error %d finding domain name", rc); 563 cERROR(1, "error %d finding domain name", rc);
567 goto setup_ntlmv2_rsp_ret; 564 goto setup_ntlmv2_rsp_ret;
@@ -594,12 +591,14 @@ setup_ntlmv2_rsp(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
594 591
595 memcpy(ses->auth_key.response + baselen, ses->tiblob, ses->tilen); 592 memcpy(ses->auth_key.response + baselen, ses->tiblob, ses->tilen);
596 593
597 /* calculate buf->ntlmv2_hash */ 594 /* calculate ntlmv2_hash */
598 rc = calc_ntlmv2_hash(ses, nls_cp); 595 rc = calc_ntlmv2_hash(ses, nls_cp);
599 if (rc) { 596 if (rc) {
600 cERROR(1, "could not get v2 hash rc %d", rc); 597 cERROR(1, "could not get v2 hash rc %d", rc);
601 goto setup_ntlmv2_rsp_ret; 598 goto setup_ntlmv2_rsp_ret;
602 } 599 }
600
601 /* calculate first part of the client response (CR1) */
603 rc = CalcNTLMv2_response(ses); 602 rc = CalcNTLMv2_response(ses);
604 if (rc) { 603 if (rc) {
605 cERROR(1, "Could not calculate CR1 rc: %d", rc); 604 cERROR(1, "Could not calculate CR1 rc: %d", rc);
@@ -623,8 +622,6 @@ setup_ntlmv2_rsp(struct cifsSesInfo *ses, const struct nls_table *nls_cp)
623 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash, 622 rc = crypto_shash_final(&ses->server->secmech.sdeschmacmd5->shash,
624 ses->auth_key.response); 623 ses->auth_key.response);
625 624
626 return 0;
627
628setup_ntlmv2_rsp_ret: 625setup_ntlmv2_rsp_ret:
629 kfree(ses->tiblob); 626 kfree(ses->tiblob);
630 ses->tiblob = NULL; 627 ses->tiblob = NULL;