diff options
author | jsing <> | 2014-05-28 13:07:47 +0000 |
---|---|---|
committer | jsing <> | 2014-05-28 13:07:47 +0000 |
commit | 11b7ce9aaed6e67e7fb23fa5c3febf635a5e7c81 (patch) | |
tree | 38eb7a5e252ed5faa8e76893ddc332b7e97408c4 /src | |
parent | 1904ce01988b6ea0f5775507b4d812459c5b3f50 (diff) | |
download | openbsd-11b7ce9aaed6e67e7fb23fa5c3febf635a5e7c81.tar.gz openbsd-11b7ce9aaed6e67e7fb23fa5c3febf635a5e7c81.tar.bz2 openbsd-11b7ce9aaed6e67e7fb23fa5c3febf635a5e7c81.zip |
EVP_MD_CTX_create() calls malloc and can return NULL. However, only one of
the calls in libssl actually checks the return value before using it. Add
NULL checks for the remaining three calls.
ok miod@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/s3_clnt.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/s3_clnt.c | 5 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/s3_enc.c | 4 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/ssl_lib.c | 2 | ||||
-rw-r--r-- | src/lib/libssl/ssl_lib.c | 2 |
5 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/libssl/s3_clnt.c b/src/lib/libssl/s3_clnt.c index ffbd83b060..602ab03fe1 100644 --- a/src/lib/libssl/s3_clnt.c +++ b/src/lib/libssl/s3_clnt.c | |||
@@ -2458,6 +2458,11 @@ ssl3_send_client_key_exchange(SSL *s) | |||
2458 | * context data | 2458 | * context data |
2459 | */ | 2459 | */ |
2460 | ukm_hash = EVP_MD_CTX_create(); | 2460 | ukm_hash = EVP_MD_CTX_create(); |
2461 | if (ukm_hash == NULL) { | ||
2462 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2463 | ERR_R_MALLOC_FAILURE); | ||
2464 | goto err; | ||
2465 | } | ||
2461 | EVP_DigestInit(ukm_hash, | 2466 | EVP_DigestInit(ukm_hash, |
2462 | EVP_get_digestbynid(NID_id_GostR3411_94)); | 2467 | EVP_get_digestbynid(NID_id_GostR3411_94)); |
2463 | EVP_DigestUpdate(ukm_hash, | 2468 | EVP_DigestUpdate(ukm_hash, |
diff --git a/src/lib/libssl/src/ssl/s3_clnt.c b/src/lib/libssl/src/ssl/s3_clnt.c index ffbd83b060..602ab03fe1 100644 --- a/src/lib/libssl/src/ssl/s3_clnt.c +++ b/src/lib/libssl/src/ssl/s3_clnt.c | |||
@@ -2458,6 +2458,11 @@ ssl3_send_client_key_exchange(SSL *s) | |||
2458 | * context data | 2458 | * context data |
2459 | */ | 2459 | */ |
2460 | ukm_hash = EVP_MD_CTX_create(); | 2460 | ukm_hash = EVP_MD_CTX_create(); |
2461 | if (ukm_hash == NULL) { | ||
2462 | SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, | ||
2463 | ERR_R_MALLOC_FAILURE); | ||
2464 | goto err; | ||
2465 | } | ||
2461 | EVP_DigestInit(ukm_hash, | 2466 | EVP_DigestInit(ukm_hash, |
2462 | EVP_get_digestbynid(NID_id_GostR3411_94)); | 2467 | EVP_get_digestbynid(NID_id_GostR3411_94)); |
2463 | EVP_DigestUpdate(ukm_hash, | 2468 | EVP_DigestUpdate(ukm_hash, |
diff --git a/src/lib/libssl/src/ssl/s3_enc.c b/src/lib/libssl/src/ssl/s3_enc.c index c9284c395f..aa729860fe 100644 --- a/src/lib/libssl/src/ssl/s3_enc.c +++ b/src/lib/libssl/src/ssl/s3_enc.c | |||
@@ -593,6 +593,10 @@ ssl3_digest_cached_records(SSL *s) | |||
593 | for (i = 0; ssl_get_handshake_digest(i, &mask, &md); i++) { | 593 | for (i = 0; ssl_get_handshake_digest(i, &mask, &md); i++) { |
594 | if ((mask & ssl_get_algorithm2(s)) && md) { | 594 | if ((mask & ssl_get_algorithm2(s)) && md) { |
595 | s->s3->handshake_dgst[i] = EVP_MD_CTX_create(); | 595 | s->s3->handshake_dgst[i] = EVP_MD_CTX_create(); |
596 | if (s->s3->handshake_dgst[i] == NULL) { | ||
597 | SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, | ||
598 | ERR_R_MALLOC_FAILURE); | ||
599 | } | ||
596 | EVP_DigestInit_ex(s->s3->handshake_dgst[i], md, NULL); | 600 | EVP_DigestInit_ex(s->s3->handshake_dgst[i], md, NULL); |
597 | EVP_DigestUpdate(s->s3->handshake_dgst[i], hdata, hdatalen); | 601 | EVP_DigestUpdate(s->s3->handshake_dgst[i], hdata, hdatalen); |
598 | } else { | 602 | } else { |
diff --git a/src/lib/libssl/src/ssl/ssl_lib.c b/src/lib/libssl/src/ssl/ssl_lib.c index bf98354294..12d45ea025 100644 --- a/src/lib/libssl/src/ssl/ssl_lib.c +++ b/src/lib/libssl/src/ssl/ssl_lib.c | |||
@@ -3235,7 +3235,7 @@ ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md) | |||
3235 | { | 3235 | { |
3236 | ssl_clear_hash_ctx(hash); | 3236 | ssl_clear_hash_ctx(hash); |
3237 | *hash = EVP_MD_CTX_create(); | 3237 | *hash = EVP_MD_CTX_create(); |
3238 | if (md) | 3238 | if (*hash != NULL && md != NULL) |
3239 | EVP_DigestInit_ex(*hash, md, NULL); | 3239 | EVP_DigestInit_ex(*hash, md, NULL); |
3240 | return (*hash); | 3240 | return (*hash); |
3241 | } | 3241 | } |
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index bf98354294..12d45ea025 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
@@ -3235,7 +3235,7 @@ ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md) | |||
3235 | { | 3235 | { |
3236 | ssl_clear_hash_ctx(hash); | 3236 | ssl_clear_hash_ctx(hash); |
3237 | *hash = EVP_MD_CTX_create(); | 3237 | *hash = EVP_MD_CTX_create(); |
3238 | if (md) | 3238 | if (*hash != NULL && md != NULL) |
3239 | EVP_DigestInit_ex(*hash, md, NULL); | 3239 | EVP_DigestInit_ex(*hash, md, NULL); |
3240 | return (*hash); | 3240 | return (*hash); |
3241 | } | 3241 | } |