From: Matt Caswell Date: Wed, 22 Jun 2016 13:37:57 +0000 (+0100) Subject: Make sure we call ssl3_digest_cached_records() when necessary X-Git-Tag: OpenSSL_1_1_0-pre6~204 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=149c2ef5ec64f246de978c5c917405dafc6983dc;p=oweals%2Fopenssl.git Make sure we call ssl3_digest_cached_records() when necessary Having received a ClientKeyExchange message instead of a Certificate we know that we are not going to receive a CertificateVerify message. This means we can free up the handshake_buffer. However we better call ssl3_digest_cached_records() instead of just freeing it up, otherwise we later try and use it anyway and a core dump results. This could happen, for example, in SSLv3 where we send a CertificateRequest but the client sends no Certificate message at all. This is valid in SSLv3 (in TLS clients are required to send an empty Certificate message). Found using the BoringSSL test suite. Reviewed-by: Emilia Käsper --- diff --git a/ssl/statem/statem_srvr.c b/ssl/statem/statem_srvr.c index c011523228..477af27108 100644 --- a/ssl/statem/statem_srvr.c +++ b/ssl/statem/statem_srvr.c @@ -2587,17 +2587,16 @@ WORK_STATE tls_post_process_client_key_exchange(SSL *s, WORK_STATE wst) } #endif - if (s->statem.no_cert_verify) { - /* No certificate verify so we no longer need the handshake_buffer */ - BIO_free(s->s3->handshake_buffer); - s->s3->handshake_buffer = NULL; + if (s->statem.no_cert_verify || !s->session->peer) { + /* No certificate verify or no peer certificate so we no longer need the + * handshake_buffer + */ + if (!ssl3_digest_cached_records(s, 0)) { + ossl_statem_set_error(s); + return WORK_ERROR; + } return WORK_FINISHED_CONTINUE; } else { - if (!s->session->peer) { - /* No peer certificate so we no longer need the handshake_buffer */ - BIO_free(s->s3->handshake_buffer); - return WORK_FINISHED_CONTINUE; - } if (!s->s3->handshake_buffer) { SSLerr(SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR);