From 2d149b2866e29906b49da088ba99bba24275877c Mon Sep 17 00:00:00 2001
From: jsing <>
Date: Sun, 24 Jul 2022 14:31:37 +0000
Subject: Set NULL BIOs for QUIC.

When used with QUIC, the SSL BIOs are effectively unused, however we still
currently expect them to exist for status (such as SSL_ERROR_WANT_READ and
SSL_ERROR_WANT_WRITE). Set up NULL BIOs if QUIC is in use.

ok tb@
---
 src/lib/libssl/tls13_quic.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

(limited to 'src/lib')

diff --git a/src/lib/libssl/tls13_quic.c b/src/lib/libssl/tls13_quic.c
index 3f814188a7..52e09f03eb 100644
--- a/src/lib/libssl/tls13_quic.c
+++ b/src/lib/libssl/tls13_quic.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: tls13_quic.c,v 1.1 2022/07/24 14:28:16 jsing Exp $ */
+/*	$OpenBSD: tls13_quic.c,v 1.2 2022/07/24 14:31:37 jsing Exp $ */
 /*
  * Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
  *
@@ -127,9 +127,22 @@ static const struct tls13_record_layer_callbacks quic_rl_callbacks = {
 int
 tls13_quic_init(struct tls13_ctx *ctx)
 {
+	BIO *bio;
+
 	tls13_record_layer_set_callbacks(ctx->rl, &quic_rl_callbacks, ctx);
 
 	ctx->middlebox_compat = 0;
 
+	/*
+	 * QUIC does not use BIOs, however we currently expect a BIO to exist
+	 * for status handling.
+	 */
+	if ((bio = BIO_new(BIO_s_null())) == NULL)
+		return 0;
+
+	BIO_up_ref(bio);
+	SSL_set_bio(ctx->ssl, bio, bio);
+	bio = NULL;
+
 	return 1;
 }
-- 
cgit v1.2.3-55-g6feb