ssl3_digest_cached_records: check for NULL after allocating s->s3->handshake_dgst
authorJonas Maebe <jonas.maebe@elis.ugent.be>
Mon, 9 Dec 2013 15:45:44 +0000 (16:45 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Wed, 10 Dec 2014 17:35:17 +0000 (18:35 +0100)
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matt Caswell <matt@openssl.org>
ssl/s3_enc.c

index f7de30ba4d87f80a4b60dd1273b1cd609ff8c9db..66f52801794e968dcddf5c272a7ea2a7dda22809 100644 (file)
@@ -616,6 +616,11 @@ int ssl3_digest_cached_records(SSL *s)
        /* Allocate handshake_dgst array */
        ssl3_free_digest_list(s);
        s->s3->handshake_dgst = OPENSSL_malloc(SSL_MAX_DIGEST * sizeof(EVP_MD_CTX *));
+       if (s->s3->handshake_dgst == NULL)
+               {
+               SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, ERR_R_MALLOC_FAILURE);
+               return 0;
+               }
        memset(s->s3->handshake_dgst,0,SSL_MAX_DIGEST *sizeof(EVP_MD_CTX *));
        hdatalen = BIO_get_mem_data(s->s3->handshake_buffer,&hdata);
        if (hdatalen <= 0)