diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2013-12-14 13:55:48 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2013-12-18 13:27:15 +0000 |
commit | a32ba49352258067cdb6ae796481557614153c57 (patch) | |
tree | e1c2bdcf719deb59e329a61e44e1f1bfe3c86603 /ssl/t1_enc.c | |
parent | 3a0c71541b94b64f3f8de2e71c261c45c69e3a45 (diff) |
Check EVP errors for handshake digests.
Partial mitigation of PR#3200
(cherry picked from commit 0294b2be5f4c11e60620c0018674ff0e17b14238)
Diffstat (limited to 'ssl/t1_enc.c')
-rw-r--r-- | ssl/t1_enc.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c index c35270706b..9eac36aa05 100644 --- a/ssl/t1_enc.c +++ b/ssl/t1_enc.c @@ -939,18 +939,19 @@ int tls1_final_finish_mac(SSL *s, if (mask & ssl_get_algorithm2(s)) { int hashsize = EVP_MD_size(md); - if (hashsize < 0 || hashsize > (int)(sizeof buf - (size_t)(q-buf))) + EVP_MD_CTX *hdgst = s->s3->handshake_dgst[idx]; + if (!hdgst || hashsize < 0 || hashsize > (int)(sizeof buf - (size_t)(q-buf))) { /* internal error: 'buf' is too small for this cipersuite! */ err = 1; } else { - EVP_MD_CTX_copy_ex(&ctx,s->s3->handshake_dgst[idx]); - EVP_DigestFinal_ex(&ctx,q,&i); - if (i != (unsigned int)hashsize) /* can't really happen */ + if (!EVP_MD_CTX_copy_ex(&ctx, hdgst) || + !EVP_DigestFinal_ex(&ctx,q,&i) || + (i != (unsigned int)hashsize)) err = 1; - q+=i; + q+=hashsize; } } } |