]> git.ipfire.org Git - thirdparty/openssl.git/commit
Move freeing of BIOs as late as possible
authorMatt Caswell <matt@openssl.org>
Tue, 18 Oct 2022 11:23:40 +0000 (12:23 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 20 Oct 2022 13:39:33 +0000 (14:39 +0100)
commitcd6e89b6b6ebe204cc442da9b563213bd67eb27f
tree6f44da305bba1108ada83dbbf6a2b0fb9d24a930
parentb92fc4ae189fb0d5b0a2f34bc28e59cd7e1eed5a
Move freeing of BIOs as late as possible

Calling SSL_free() will call BIO_free_all() on the rbio and wbio. We
keep references to the rbio and wbio inside the record layer object.
References to that object are held directly, as well as in fragment
retransmission queues. We need to ensure all record layer objects are
cleaned up before we call BIO_free_all() on rbio/wbio - otherwise the
"top" BIO may not have its reference count drop to 0 when BIO_free_all()
is called. This means that the rest of the BIOs in the chain don't get
freed and a memory leak can occur.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19424)
ssl/ssl_lib.c