Ensure we up-ref the sbio before passing it to tserver
authorMatt Caswell <matt@openssl.org>
Wed, 20 Sep 2023 15:24:37 +0000 (16:24 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 22 Sep 2023 12:56:43 +0000 (13:56 +0100)
We are actually passing two references to sbio: one as part of a BIO chain
and one stand alone. Therefore we need two references.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22157)

test/helpers/quictestlib.c

index 6a72cc27bea226e95a2dc75fc69a0464a15e9f9c..f5a46efb6f01601acd25be95015290b6dda4c640 100644 (file)
@@ -201,8 +201,12 @@ int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx,
 
     BIO_set_data(fisbio, fault == NULL ? NULL : *fault);
 
-    if (!TEST_ptr(BIO_push(fisbio, sbio)))
+    if (!BIO_up_ref(sbio))
         goto err;
+    if (!TEST_ptr(BIO_push(fisbio, sbio))) {
+        BIO_free(sbio);
+        goto err;
+    }
 
     tserver_args.libctx = libctx;
     tserver_args.net_rbio = sbio;
@@ -240,7 +244,7 @@ int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx,
     SSL_CTX_free(tserver_args.ctx);
     BIO_ADDR_free(peeraddr);
     BIO_free_all(cbio);
-    BIO_free(fisbio);
+    BIO_free_all(fisbio);
     BIO_free_all(sbio);
     SSL_free(*cssl);
     *cssl = NULL;