Skip to content

Commit

Permalink
Curl_ssl_md5sum: return CURLcode
Browse files Browse the repository at this point in the history
... since the funciton can fail on OOM. Check this return code.

Coverity CID 1291705.
  • Loading branch information
bagder committed Mar 25, 2015
1 parent e35f2e6 commit 4e29919
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
10 changes: 5 additions & 5 deletions lib/curl_ntlm_msgs.c
Expand Up @@ -591,11 +591,11 @@ CURLcode Curl_sasl_create_ntlm_type3_message(struct SessionHandle *data,
memcpy(tmp, &ntlm->nonce[0], 8);
memcpy(tmp + 8, entropy, 8);

Curl_ssl_md5sum(tmp, 16, md5sum, MD5_DIGEST_LENGTH);

/* We shall only use the first 8 bytes of md5sum, but the des
code in Curl_ntlm_core_lm_resp only encrypt the first 8 bytes */
result = Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer);
result = Curl_ssl_md5sum(tmp, 16, md5sum, MD5_DIGEST_LENGTH);
if(!result)
/* We shall only use the first 8 bytes of md5sum, but the des code in
Curl_ntlm_core_lm_resp only encrypt the first 8 bytes */
result = Curl_ntlm_core_mk_nt_hash(data, passwdp, ntbuffer);
if(result)
return result;

Expand Down
11 changes: 7 additions & 4 deletions lib/vtls/vtls.c
Expand Up @@ -828,10 +828,10 @@ CURLcode Curl_pin_peer_pubkey(const char *pinnedpubkey,
}

#ifndef CURL_DISABLE_CRYPTO_AUTH
void Curl_ssl_md5sum(unsigned char *tmp, /* input */
size_t tmplen,
unsigned char *md5sum, /* output */
size_t md5len)
CURLcode Curl_ssl_md5sum(unsigned char *tmp, /* input */
size_t tmplen,
unsigned char *md5sum, /* output */
size_t md5len)
{
#ifdef curlssl_md5sum
curlssl_md5sum(tmp, tmplen, md5sum, md5len);
Expand All @@ -841,9 +841,12 @@ void Curl_ssl_md5sum(unsigned char *tmp, /* input */
(void) md5len;

MD5pw = Curl_MD5_init(Curl_DIGEST_MD5);
if(!MD5pw)
return CURLE_OUT_OF_MEMORY;
Curl_MD5_update(MD5pw, tmp, curlx_uztoui(tmplen));
Curl_MD5_final(MD5pw, md5sum);
#endif
return CURLE_OK;
}
#endif

Expand Down
8 changes: 4 additions & 4 deletions lib/vtls/vtls.h
Expand Up @@ -108,10 +108,10 @@ void Curl_ssl_delsessionid(struct connectdata *conn, void *ssl_sessionid);
in */
int Curl_ssl_random(struct SessionHandle *data, unsigned char *buffer,
size_t length);
void Curl_ssl_md5sum(unsigned char *tmp, /* input */
size_t tmplen,
unsigned char *md5sum, /* output */
size_t md5len);
CURLcode Curl_ssl_md5sum(unsigned char *tmp, /* input */
size_t tmplen,
unsigned char *md5sum, /* output */
size_t md5len);
/* Check pinned public key. */
CURLcode Curl_pin_peer_pubkey(const char *pinnedpubkey,
const unsigned char *pubkey, size_t pubkeylen);
Expand Down

0 comments on commit 4e29919

Please sign in to comment.