From: Matt Caswell Date: Tue, 13 Jul 2021 16:44:44 +0000 (+0100) Subject: Disallow SSL_key_update() if there are writes pending X-Git-Tag: OpenSSL_1_1_1l~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9d782d72f573045d0c09e1685a1125df58ecb03;p=thirdparty%2Fopenssl.git Disallow SSL_key_update() if there are writes pending If an application is halfway through writing application data it should not be allowed to attempt an SSL_key_update() operation. Instead the SSL_write() operation should be completed. Fixes #12485 Reviewed-by: Ben Kaduk Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/16098) --- diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index e1c95ddc606..ffd0a0bc6d1 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -2119,6 +2119,11 @@ int SSL_key_update(SSL *s, int updatetype) return 0; } + if (RECORD_LAYER_write_pending(&s->rlayer)) { + SSLerr(SSL_F_SSL_KEY_UPDATE, SSL_R_BAD_WRITE_RETRY); + return 0; + } + ossl_statem_set_in_init(s, 1); s->key_update = updatetype; return 1;