diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2007-04-10 22:52:50 +0000 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2007-04-10 22:52:50 +0000 |
commit | d46d995766a849dbbcfa2f362ccdbca24401a006 (patch) | |
tree | 336ea38a86bbb6c716bd21d19fc16c23383681e5 /lib/http_ntlm.c | |
parent | 1a0cc60741ad6cac8f5564ee6d96edb7b3313b0d (diff) |
Fixed some out of memory handling issues.
Diffstat (limited to 'lib/http_ntlm.c')
-rw-r--r-- | lib/http_ntlm.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/http_ntlm.c b/lib/http_ntlm.c index 8c9795b7e..573f7ad83 100644 --- a/lib/http_ntlm.c +++ b/lib/http_ntlm.c @@ -415,16 +415,14 @@ static void utf8_to_unicode_le(unsigned char *dest, const char *src, /* * Set up nt hashed passwords */ -static void mk_nt_hash(struct SessionHandle *data, - char *password, - unsigned char *ntbuffer /* 21 bytes */) +static CURLcode mk_nt_hash(struct SessionHandle *data, + char *password, + unsigned char *ntbuffer /* 21 bytes */) { size_t len = strlen(password); unsigned char *pw = malloc(len*2); if (!pw) - /* No way to report this error; just rely on future malloc failures - to be caught */ - return; + return CURLE_OUT_OF_MEMORY; utf8_to_unicode_le(pw, password, len); @@ -451,6 +449,7 @@ static void mk_nt_hash(struct SessionHandle *data, } free(pw); + return CURLE_OK; } #endif @@ -875,7 +874,8 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, MD5_Final(md5sum, &MD5); /* We shall only use the first 8 bytes of md5sum, but the des code in lm_resp only encrypt the first 8 bytes */ - mk_nt_hash(conn->data, passwdp, ntbuffer); + if (mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY) + return CURLE_OUT_OF_MEMORY; lm_resp(ntbuffer, md5sum, ntresp); /* End of NTLM2 Session code */ @@ -889,7 +889,8 @@ CURLcode Curl_output_ntlm(struct connectdata *conn, unsigned char lmbuffer[0x18]; #if USE_NTRESPONSES - mk_nt_hash(conn->data, passwdp, ntbuffer); + if (mk_nt_hash(conn->data, passwdp, ntbuffer) == CURLE_OUT_OF_MEMORY) + return CURLE_OUT_OF_MEMORY; lm_resp(ntbuffer, &ntlm->nonce[0], ntresp); #endif |