]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
QUIC TX: Do not have QTX handle refcount of BIOs
authorHugo Landau <hlandau@openssl.org>
Mon, 31 Oct 2022 15:44:08 +0000 (15:44 +0000)
committerHugo Landau <hlandau@openssl.org>
Fri, 13 Jan 2023 13:20:11 +0000 (13:20 +0000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19703)

include/internal/quic_record_tx.h
ssl/quic/quic_record_tx.c

index 6641d83dddec7fcc40166f0bc96628889a3b99ec..b0e5e148c1759586d5043963ff34d86601cced84 100644 (file)
@@ -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);
index 14c8b0bd68a6c42a983007895ccd79591c281b7e..0cea8c13f57c15f2fa7bb4f1e95be7255ea11a88 100644 (file)
@@ -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)