From 3bec48515354bc4138ce14c5aafc2c9e3bcc473f Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Tue, 13 Jul 2021 17:44:44 +0100 Subject: 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: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/16077) --- ssl/ssl_lib.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ssl/ssl_lib.c') diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index c1e8e41f02..892a417d93 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -2262,6 +2262,11 @@ int SSL_key_update(SSL *s, int updatetype) return 0; } + if (RECORD_LAYER_write_pending(&s->rlayer)) { + ERR_raise(ERR_LIB_SSL, SSL_R_BAD_WRITE_RETRY); + return 0; + } + ossl_statem_set_in_init(s, 1); s->key_update = updatetype; return 1; -- cgit v1.2.3