From: Matt Caswell Date: Thu, 19 Jan 2023 11:59:44 +0000 (+0000) Subject: Ensure our buffer allocation allows for the Explicit IV X-Git-Tag: openssl-3.2.0-alpha1~1413 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=626618a09d057db6eee34c3fdd81525b9e3cbc68;p=thirdparty%2Fopenssl.git Ensure our buffer allocation allows for the Explicit IV Some ciphers/protocol versions have an explicit IV. We need to make sure we have sufficient room for it in the underlying buffer. Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/20085) --- diff --git a/ssl/record/methods/tls_common.c b/ssl/record/methods/tls_common.c index 8b569f962a9..e34a2792d31 100644 --- a/ssl/record/methods/tls_common.c +++ b/ssl/record/methods/tls_common.c @@ -158,11 +158,15 @@ int tls_setup_write_buffer(OSSL_RECORD_LAYER *rl, size_t numwpipes, #endif defltlen = rl->max_frag_len + SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD - + headerlen + align; + + headerlen + align + rl->eivlen; #ifndef OPENSSL_NO_COMP if (tls_allow_compression(rl)) defltlen += SSL3_RT_MAX_COMPRESSED_OVERHEAD; #endif + /* + * We don't need to add eivlen here since empty fragments only occur + * when we don't have an explicit IV + */ if (!(rl->options & SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS)) defltlen += headerlen + align + SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD; }