diff options
Diffstat (limited to 'fs/cifs/cifsencrypt.c')
-rw-r--r-- | fs/cifs/cifsencrypt.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 5d9b9acc5fce..bce99e6a4950 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -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_strtoUCS((__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); |