Check return value of ssl3_output_cert_chain
authorMatt Caswell <matt@openssl.org>
Tue, 18 Mar 2014 14:19:22 +0000 (14:19 +0000)
committerMatt Caswell <matt@openssl.org>
Mon, 15 Dec 2014 21:29:49 +0000 (21:29 +0000)
Based on commit 66f96fe2d519147097c118d4bf60704c69ed0635 by Steve Henson

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit ce5ddefc4394a0ae6c79efaffe08cf47ac659ea0)

ssl/s3_clnt.c
ssl/s3_srvr.c

index 89dc06e5f8bb9ac4c69152c27efa3a8b25c34fc6..e614f9693e9273ea265ff50b4d9b95c91c9b451a 100644 (file)
@@ -2962,6 +2962,12 @@ int ssl3_send_client_certificate(SSL *s)
                s->state=SSL3_ST_CW_CERT_D;
                l=ssl3_output_cert_chain(s,
                        (s->s3->tmp.cert_req == 2)?NULL:s->cert->key->x509);
+               if (!l)
+                       {
+                       SSLerr(SSL_F_SSL3_SEND_CLIENT_CERTIFICATE, ERR_R_INTERNAL_ERROR);
+                       ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_INTERNAL_ERROR);
+                       return 0;
+                       }
                s->init_num=(int)l;
                s->init_off=0;
                }
index 546d633e344d61e529d9ee99e906e039209a1612..4573ec8b74d6f86ceffd466848f13ce50dd4866c 100644 (file)
@@ -3084,6 +3084,11 @@ int ssl3_send_server_certificate(SSL *s)
                        }
 
                l=ssl3_output_cert_chain(s,x);
+               if (!l)
+                       {
+                       SSLerr(SSL_F_SSL3_SEND_SERVER_CERTIFICATE,ERR_R_INTERNAL_ERROR);
+                       return(0);
+                       }
                s->state=SSL3_ST_SW_CERT_B;
                s->init_num=(int)l;
                s->init_off=0;