From 2c55b28a34624c18e3d05dfd7acb78895e3a64e6 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Fri, 3 Feb 2017 14:45:49 +0000 Subject: [PATCH] Remove an OPENSSL_assert() and replace with a soft assert and check Following on from CVE-2017-3733, this removes the OPENSSL_assert() check that failed and replaces it with a soft assert, and an explicit check of value with an error return if it fails. Reviewed-by: Richard Levitte --- ssl/record/ssl3_record.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ssl/record/ssl3_record.c b/ssl/record/ssl3_record.c index 9e99210d89..df7d012049 100644 --- a/ssl/record/ssl3_record.c +++ b/ssl/record/ssl3_record.c @@ -7,6 +7,7 @@ * https://www.openssl.org/source/license.html */ +#include #include "../ssl_locl.h" #include "internal/constant_time_locl.h" #include @@ -387,13 +388,13 @@ int ssl3_get_record(SSL *s) unsigned char *mac; /* TODO(size_t): convert this to do size_t properly */ imac_size = EVP_MD_CTX_size(s->read_hash); - if (imac_size < 0) { + assert(imac_size >= 0 && imac_size <= EVP_MAX_MD_SIZE); + if (imac_size < 0 || imac_size > EVP_MAX_MD_SIZE) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_RECORD, ERR_LIB_EVP); goto f_err; } mac_size = (size_t)imac_size; - OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE); for (j = 0; j < num_recs; j++) { thisrr = &rr[j]; -- 2.25.1