Skip to content

Commit

Permalink
ntlm: Return CURLcode from Curl_ntlm_core_mk_lm_hash()
Browse files Browse the repository at this point in the history
  • Loading branch information
captain-caveman2k committed Oct 26, 2014
1 parent 9c5f851 commit 3b738a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/curl_ntlm_core.c
Expand Up @@ -311,9 +311,9 @@ void Curl_ntlm_core_lm_resp(const unsigned char *keys,
/*
* Set up lanmanager hashed password
*/
void Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data,
const char *password,
unsigned char *lmbuffer /* 21 bytes */)
CURLcode Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data,
const char *password,
unsigned char *lmbuffer /* 21 bytes */)
{
CURLcode result;
unsigned char pw[14];
Expand All @@ -331,7 +331,7 @@ void Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data,
*/
result = Curl_convert_to_network(data, (char *)pw, 14);
if(result)
return;
return result;

{
/* Create LanManager hashed password. */
Expand Down Expand Up @@ -371,6 +371,8 @@ void Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data,

memset(lmbuffer + 16, 0, 21 - 16);
}

return CURLE_OK;
}

#if USE_NTRESPONSES
Expand Down
6 changes: 3 additions & 3 deletions lib/curl_ntlm_core.h
Expand Up @@ -53,9 +53,9 @@ void Curl_ntlm_core_lm_resp(const unsigned char *keys,
const unsigned char *plaintext,
unsigned char *results);

void Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data,
const char *password,
unsigned char *lmbuffer /* 21 bytes */);
CURLcode Curl_ntlm_core_mk_lm_hash(struct SessionHandle *data,
const char *password,
unsigned char *lmbuffer /* 21 bytes */);

#if USE_NTRESPONSES
CURLcode Curl_hmac_md5(const unsigned char *key, unsigned int keylen,
Expand Down
6 changes: 5 additions & 1 deletion lib/curl_ntlm_msgs.c
Expand Up @@ -830,8 +830,12 @@ CURLcode Curl_ntlm_create_type3_message(struct SessionHandle *data,
Curl_ntlm_core_lm_resp(ntbuffer, &ntlm->nonce[0], ntresp);
#endif

Curl_ntlm_core_mk_lm_hash(data, passwdp, lmbuffer);
result = Curl_ntlm_core_mk_lm_hash(data, passwdp, lmbuffer);
if(result)
return result;

Curl_ntlm_core_lm_resp(lmbuffer, &ntlm->nonce[0], lmresp);

/* A safer but less compatible alternative is:
* Curl_ntlm_core_lm_resp(ntbuffer, &ntlm->nonce[0], lmresp);
* See http://davenport.sourceforge.net/ntlm.html#ntlmVersion2 */
Expand Down

0 comments on commit 3b738a1

Please sign in to comment.