The ssl3_digest_cached_records() function does not handle errors properly
authorMatt Caswell <matt@openssl.org>
Thu, 26 May 2016 14:45:14 +0000 (15:45 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 26 May 2016 14:47:33 +0000 (15:47 +0100)
The ssl3_digest_cached_records() function was failing to handle errors
that might be returned from EVP_DigestSignInit() and
EVP_DigestSignUpdate().

RT#4180

Reviewed-by: Stephen Henson <steve@openssl.org>
ssl/s3_enc.c

index c1222a72c21d15edc239b62a7a3ef909ed06f488..cb571c1d07ff3b6686ecbf91440a413f46a07d55 100644 (file)
@@ -374,14 +374,13 @@ int ssl3_digest_cached_records(SSL *s, int keep)
         }
 
         md = ssl_handshake_md(s);
-        if (md == NULL) {
+        if (   md == NULL
+            || !EVP_DigestInit_ex(s->s3->handshake_dgst, md, NULL)
+            || !EVP_DigestUpdate(s->s3->handshake_dgst, hdata, hdatalen))
+        {
             SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, ERR_R_INTERNAL_ERROR);
             return 0;
         }
-
-        EVP_DigestInit_ex(s->s3->handshake_dgst, md, NULL);
-        EVP_DigestUpdate(s->s3->handshake_dgst, hdata, hdatalen);
-
     }
     if (keep == 0) {
         BIO_free(s->s3->handshake_buffer);