]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Disallow SSL_key_update() if there are writes pending
authorMatt Caswell <matt@openssl.org>
Tue, 13 Jul 2021 16:44:44 +0000 (17:44 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 16 Jul 2021 10:32:44 +0000 (11:32 +0100)
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 <kaduk@mit.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16098)

ssl/ssl_lib.c

index e1c95ddc6064e872169427237be1eba8748a73e0..ffd0a0bc6d1763b71f1648d88cc2e32922d39c0a 100644 (file)
@@ -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;