aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifsencrypt.c
diff options
context:
space:
mode:
authorShirish Pargaonkar <shirishpargaonkar@gmail.com>2010-10-26 19:10:24 -0400
committerSteve French <sfrench@us.ibm.com>2010-10-26 22:04:30 -0400
commitf7c5445a9deecffea8a4fffc0163bf582411ac8a (patch)
treeefea64611599a034510be60077ca20bed68a48e8 /fs/cifs/cifsencrypt.c
parent307fbd31b61623ad1b5388b452118f8aea99f9d0 (diff)
NTLM auth and sign - minor error corrections and cleanup
Minor cleanup - Fix spelling mistake, make meaningful (goto) label In function setup_ntlmv2_rsp(), do not return 0 and leak memory, let the tiblob get freed. For function find_domain_name(), pass already available nls table pointer instead of loading and unloading the table again in this function. For ntlmv2, the case sensitive password length is the length of the response, so subtract session key length (16 bytes) from the .len. Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
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;