From 8b64375fec195dcaddae6b74c779075f3c95eb8b Mon Sep 17 00:00:00 2001 From: Hugo Landau Date: Mon, 5 Feb 2024 16:17:37 +0000 Subject: [PATCH] QUIC APL: Fix server API bugs discovered during test Reviewed-by: Matt Caswell Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/23334) --- ssl/quic/quic_impl.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index aa42f4f64d3..e474ba9497d 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -521,6 +521,18 @@ err: return NULL; } +QUIC_NEEDS_LOCK +static void quic_unref_port_bios(QUIC_PORT *port) +{ + BIO *b; + + b = ossl_quic_port_get_net_rbio(port); + BIO_free_all(b); + + b = ossl_quic_port_get_net_wbio(port); + BIO_free_all(b); +} + QUIC_NEEDS_LOCK static void qc_cleanup(QUIC_CONNECTION *qc, int have_lock) { @@ -530,15 +542,8 @@ static void qc_cleanup(QUIC_CONNECTION *qc, int have_lock) ossl_quic_channel_free(qc->ch); qc->ch = NULL; - if (qc->port != NULL) { - BIO *b; - - b = ossl_quic_port_get_net_rbio(qc->port); - BIO_free_all(b); - - b = ossl_quic_port_get_net_wbio(qc->port); - BIO_free_all(b); - + if (qc->port != NULL && qc->listener == NULL) { /* TODO */ + quic_unref_port_bios(qc->port); ossl_quic_port_free(qc->port); qc->port = NULL; } @@ -559,6 +564,7 @@ static void qc_cleanup(QUIC_CONNECTION *qc, int have_lock) QUIC_TAKES_LOCK static void quic_free_listener(QCTX *ctx) { + quic_unref_port_bios(ctx->ql->port); ossl_quic_port_free(ctx->ql->port); ossl_quic_engine_free(ctx->ql->engine); ossl_crypto_mutex_free(&ctx->ql->mutex); @@ -1183,12 +1189,12 @@ int ossl_quic_handle_events(SSL *s) { QCTX ctx; - if (!expect_quic(s, &ctx)) + if (!expect_quic_any(s, &ctx)) return 0; qctx_lock(&ctx); if (ctx.qc->started) - ossl_quic_reactor_tick(ossl_quic_channel_get_reactor(ctx.qc->ch), 0); + ossl_quic_reactor_tick(ossl_quic_obj_get0_reactor(ctx.obj), 0); qctx_unlock(&ctx); return 1; } @@ -4109,6 +4115,7 @@ static int ql_listen(QUIC_LISTENER *ql) if (ql->listening) return 1; + ossl_quic_port_set_allow_incoming(ql->port, 1); ql->listening = 1; return 1; } -- 2.47.2