From: Hugo Landau Date: Mon, 31 Oct 2022 15:44:08 +0000 (+0000) Subject: QUIC TX: Do not have QTX handle refcount of BIOs X-Git-Tag: openssl-3.2.0-alpha1~1521 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdd3f7323613aaaf316b0b2d3a7700fbc602c8ef;p=thirdparty%2Fopenssl.git QUIC TX: Do not have QTX handle refcount of BIOs Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/19703) --- diff --git a/include/internal/quic_record_tx.h b/include/internal/quic_record_tx.h index 6641d83ddde..b0e5e148c17 100644 --- a/include/internal/quic_record_tx.h +++ b/include/internal/quic_record_tx.h @@ -240,9 +240,10 @@ size_t ossl_qtx_get_unflushed_pkt_count(OSSL_QTX *qtx); /* * Change the BIO being used by the QTX. May be NULL if actual transmission is - * not currently required. + * not currently required. Does not ref the BIO; the caller is responsible for + * ensuring the lifetime of the BIO exceeds the lifetime of the QTX. */ -int ossl_qtx_set1_bio(OSSL_QTX *qtx, BIO *bio); +void ossl_qtx_set_bio(OSSL_QTX *qtx, BIO *bio); /* Changes the MDPL. */ int ossl_qtx_set_mdpl(OSSL_QTX *qtx, size_t mdpl); diff --git a/ssl/quic/quic_record_tx.c b/ssl/quic/quic_record_tx.c index 14c8b0bd68a..0cea8c13f57 100644 --- a/ssl/quic/quic_record_tx.c +++ b/ssl/quic/quic_record_tx.c @@ -104,11 +104,6 @@ OSSL_QTX *ossl_qtx_new(const OSSL_QTX_ARGS *args) if (qtx == NULL) return 0; - if (args->bio != NULL && !BIO_up_ref(args->bio)) { - OPENSSL_free(qtx); - return 0; - } - qtx->libctx = args->libctx; qtx->propq = args->propq; qtx->bio = args->bio; @@ -143,7 +138,6 @@ void ossl_qtx_free(OSSL_QTX *qtx) for (i = 0; i < QUIC_ENC_LEVEL_NUM; ++i) ossl_qrl_enc_level_set_discard(&qtx->el_set, i); - BIO_free(qtx->bio); OPENSSL_free(qtx); } @@ -864,14 +858,9 @@ int ossl_qtx_pop_net(OSSL_QTX *qtx, BIO_MSG *msg) return 1; } -int ossl_qtx_set1_bio(OSSL_QTX *qtx, BIO *bio) +void ossl_qtx_set_bio(OSSL_QTX *qtx, BIO *bio) { - if (bio != NULL && !BIO_up_ref(bio)) - return 0; - - BIO_free(qtx->bio); qtx->bio = bio; - return 1; } int ossl_qtx_set_mdpl(OSSL_QTX *qtx, size_t mdpl)