Fix some malloc failure crashes on X509_STORE_CTX_set_ex_data
authorFdaSilvaYY <fdasilvayy@gmail.com>
Sat, 13 Feb 2016 18:01:14 +0000 (19:01 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 23 May 2016 12:42:37 +0000 (13:42 +0100)
from BoringSSL 306ece31bcaaed49e0240a2e5555f8901ebb2d45

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
ssl/ssl_cert.c

index f285fbe..7481705 100644 (file)
@@ -409,7 +409,9 @@ int ssl_verify_cert_chain(SSL *s, STACK_OF(X509) *sk)
 
     /* Set suite B flags if needed */
     X509_STORE_CTX_set_flags(ctx, tls1_suiteb(s));
-    X509_STORE_CTX_set_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx(), s);
+    if (!X509_STORE_CTX_set_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx(), s)) {
+        goto end;
+    }
 
     /* Verify via DANE if enabled */
     if (DANETLS_ENABLED(&s->dane))