From bc8a449ef7409ffe1e859d3e526e8d2a9f693d3d Mon Sep 17 00:00:00 2001 From: Joshua Rogers Date: Sun, 12 Oct 2025 05:43:38 +0800 Subject: [PATCH] crypto/bio/bss_acpt: set b->init only on successful BIO_parse_hostserv MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit BIO_C_SET_ACCEPT with num == 0 unconditionally set b->init = 1 even if BIO_parse_hostserv failed. Only mark the BIO initialized when parsing succeeds to avoid inconsistent state. Signed-off-by: Joshua Rogers Reviewed-by: Saša Nedvědický Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/28912) --- crypto/bio/bss_acpt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c index 23f933ce4c8..7c55cc05def 100644 --- a/crypto/bio/bss_acpt.c +++ b/crypto/bio/bss_acpt.c @@ -436,7 +436,8 @@ static long acpt_ctrl(BIO *b, int cmd, long num, void *ptr) BIO_PARSE_PRIO_SERV); if (hold_serv != data->param_serv) OPENSSL_free(hold_serv); - b->init = 1; + if (ret > 0) + b->init = 1; } else if (num == 1) { OPENSSL_free(data->param_serv); if ((data->param_serv = OPENSSL_strdup(ptr)) == NULL) -- 2.47.3