mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
ntlm: Updated Curl_ntlm_core_mk_ntlmv2_resp() to use local variables
...until the function is successful when it returns them in the out parameters.
This commit is contained in:
parent
07b66cbfa4
commit
914b60c827
@ -547,6 +547,7 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
|
|||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
unsigned int len = 0;
|
||||||
unsigned char *ptr = NULL;
|
unsigned char *ptr = NULL;
|
||||||
unsigned char hmac_output[NTLM_HMAC_MD5_LEN];
|
unsigned char hmac_output[NTLM_HMAC_MD5_LEN];
|
||||||
long long tw;
|
long long tw;
|
||||||
@ -556,15 +557,14 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
|
|||||||
tw = ((long long)time(NULL) + 11644473600ULL) * 10000000ULL;
|
tw = ((long long)time(NULL) + 11644473600ULL) * 10000000ULL;
|
||||||
|
|
||||||
/* Calculate the response len */
|
/* Calculate the response len */
|
||||||
*ntresp_len = NTLM_HMAC_MD5_LEN + NTLMv2_BLOB_LEN;
|
len = NTLM_HMAC_MD5_LEN + NTLMv2_BLOB_LEN;
|
||||||
|
|
||||||
/* Allocate the response */
|
/* Allocate the response */
|
||||||
*ntresp = malloc(*ntresp_len);
|
ptr = malloc(len);
|
||||||
if(!*ntresp)
|
if(!ptr)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
|
||||||
ptr = *ntresp;
|
memset(ptr, 0, len);
|
||||||
memset(ptr, 0, *ntresp_len);
|
|
||||||
|
|
||||||
/* Create the BLOB structure */
|
/* Create the BLOB structure */
|
||||||
snprintf((char *)ptr + NTLM_HMAC_MD5_LEN, NTLMv2_BLOB_LEN,
|
snprintf((char *)ptr + NTLM_HMAC_MD5_LEN, NTLMv2_BLOB_LEN,
|
||||||
@ -581,14 +581,17 @@ CURLcode Curl_ntlm_core_mk_ntlmv2_resp(unsigned char *ntlmv2hash,
|
|||||||
res = Curl_hmac_md5(ntlmv2hash, NTLM_HMAC_MD5_LEN, ptr + 8,
|
res = Curl_hmac_md5(ntlmv2hash, NTLM_HMAC_MD5_LEN, ptr + 8,
|
||||||
NTLMv2_BLOB_LEN + 8, hmac_output);
|
NTLMv2_BLOB_LEN + 8, hmac_output);
|
||||||
if(res) {
|
if(res) {
|
||||||
Curl_safefree(*ntresp);
|
Curl_safefree(ptr);
|
||||||
*ntresp_len = 0;
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Concatenate the HMAC MD5 output with the BLOB */
|
/* Concatenate the HMAC MD5 output with the BLOB */
|
||||||
memcpy(ptr, hmac_output, NTLM_HMAC_MD5_LEN);
|
memcpy(ptr, hmac_output, NTLM_HMAC_MD5_LEN);
|
||||||
|
|
||||||
|
/* Return the response */
|
||||||
|
*ntresp = ptr;
|
||||||
|
*ntresp_len = len;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user