From: Frederik Wedel-Heinen Date: Tue, 7 May 2024 19:18:44 +0000 (+0200) Subject: Clear old messages from queues in order to avoid leaks of record layer objects. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4461dba43f7cb86e02f4ef9538345c4dd3f2176;p=thirdparty%2Fopenssl.git Clear old messages from queues in order to avoid leaks of record layer objects. Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/22275) --- diff --git a/ssl/tls13_enc.c b/ssl/tls13_enc.c index ae76ddb3f45..e17154d952a 100644 --- a/ssl/tls13_enc.c +++ b/ssl/tls13_enc.c @@ -758,6 +758,14 @@ int tls13_change_cipher_state(SSL_CONNECTION *s, int which) ? OSSL_RECORD_PROTECTION_LEVEL_HANDSHAKE : OSSL_RECORD_PROTECTION_LEVEL_APPLICATION); + if (SSL_CONNECTION_IS_DTLS(s)) { + /* We have moved to the next flight lets clear out old messages */ + if (direction == OSSL_RECORD_DIRECTION_READ) + dtls1_clear_received_buffer(s); + else + dtls1_clear_sent_buffer(s); + } + if (!ssl_set_new_record_layer(s, s->version, direction, level, secret, hashlen, key, keylen, iv, diff --git a/test/tls13secretstest.c b/test/tls13secretstest.c index 2cbc4521308..5109857ec32 100644 --- a/test/tls13secretstest.c +++ b/test/tls13secretstest.c @@ -236,6 +236,14 @@ int ssl_set_new_record_layer(SSL_CONNECTION *s, int version, int direction, return 0; } +void dtls1_clear_received_buffer(SSL_CONNECTION *s) +{ +} + +void dtls1_clear_sent_buffer(SSL_CONNECTION *s) +{ +} + /* End of mocked out code */ static int test_secret(SSL_CONNECTION *s, unsigned char *prk,