From: Matt Caswell Date: Thu, 23 Nov 2017 12:33:11 +0000 (+0000) Subject: Assert that SSLfatal() only gets called once X-Git-Tag: OpenSSL_1_1_1-pre1~385 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=f9f674eb76a7c00e3f158f673a7ec01286b02907 Assert that SSLfatal() only gets called once We shouldn't call SSLfatal() multiple times for the same error condition. Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/4778) --- diff --git a/ssl/statem/statem.c b/ssl/statem/statem.c index 5c158fa24d..fe348419cd 100644 --- a/ssl/statem/statem.c +++ b/ssl/statem/statem.c @@ -11,6 +11,7 @@ #include #include "../ssl_locl.h" #include "statem_locl.h" +#include /* * This file implements the SSL/TLS/DTLS state machines. @@ -117,6 +118,8 @@ void ossl_statem_set_renegotiate(SSL *s) void ossl_statem_fatal(SSL *s, int al, int func, int reason, const char *file, int line) { + /* We shouldn't call SSLfatal() twice. Once is enough */ + assert(s->statem.state != MSG_FLOW_ERROR); s->statem.in_init = 1; s->statem.state = MSG_FLOW_ERROR; ERR_put_error(ERR_LIB_SSL, func, reason, file, line); diff --git a/ssl/statem/statem_clnt.c b/ssl/statem/statem_clnt.c index 4bd94572bb..038fac93c6 100644 --- a/ssl/statem/statem_clnt.c +++ b/ssl/statem/statem_clnt.c @@ -2938,10 +2938,12 @@ static int tls_construct_cke_dhe(SSL *s, WPACKET *pkt) return 1; err: EVP_PKEY_free(ckey); -#endif + return 0; +#else SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_DHE, ERR_R_INTERNAL_ERROR); return 0; +#endif } static int tls_construct_cke_ecdhe(SSL *s, WPACKET *pkt)