Ensure we free all the BIOs in a chain for QUIC like we do in TLS

An application may pass in a whole BIO chain via SSL_set_bio(). When we
free the BIO we should be using BIO_free_all() not BIO_free() like we do
with TLS.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22157)
This commit is contained in:
Matt Caswell 2023-09-20 16:25:44 +01:00
parent f13f9b716e
commit 18fd0ea04d
3 changed files with 8 additions and 10 deletions

View File

@ -545,8 +545,8 @@ void ossl_quic_free(SSL *s)
ossl_quic_channel_free(ctx.qc->ch);
BIO_free(ctx.qc->net_rbio);
BIO_free(ctx.qc->net_wbio);
BIO_free_all(ctx.qc->net_rbio);
BIO_free_all(ctx.qc->net_wbio);
/* Note: SSL_free calls OPENSSL_free(qc) for us */
@ -876,7 +876,7 @@ void ossl_quic_conn_set0_net_rbio(SSL *s, BIO *net_rbio)
if (!ossl_quic_channel_set_net_rbio(ctx.qc->ch, net_rbio))
return;
BIO_free(ctx.qc->net_rbio);
BIO_free_all(ctx.qc->net_rbio);
ctx.qc->net_rbio = net_rbio;
if (net_rbio != NULL)
@ -903,7 +903,7 @@ void ossl_quic_conn_set0_net_wbio(SSL *s, BIO *net_wbio)
if (!ossl_quic_channel_set_net_wbio(ctx.qc->ch, net_wbio))
return;
BIO_free(ctx.qc->net_wbio);
BIO_free_all(ctx.qc->net_wbio);
ctx.qc->net_wbio = net_wbio;
if (net_wbio != NULL)

View File

@ -159,8 +159,8 @@ void ossl_quic_tserver_free(QUIC_TSERVER *srv)
return;
ossl_quic_channel_free(srv->ch);
BIO_free(srv->args.net_rbio);
BIO_free(srv->args.net_wbio);
BIO_free_all(srv->args.net_rbio);
BIO_free_all(srv->args.net_wbio);
OPENSSL_free(srv->ssl);
SSL_free(srv->tls);
SSL_CTX_free(srv->ctx);

View File

@ -746,10 +746,8 @@ static int helper_init(struct helper *h, int free_order, int blocking,
BIO_set_data(h->s_qtf_wbio, h->qtf);
}
if (!need_injector)
h->s_net_bio_own = NULL;
h->s_qtf_wbio_own = NULL;
h->s_net_bio_own = NULL;
h->s_qtf_wbio_own = NULL;
h->c_fd = BIO_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP, 0);
if (!TEST_int_ge(h->c_fd, 0))