From 7b7a4678bd971aaaea5a805b4970bd6350fa7d25 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sat, 9 May 2020 08:39:44 +0000 Subject: Pull the sending of alerts up into tls13_handshake_perform(). This fixes the case where a send function signals that an alert should be sent, then returns failure. Previously the failure would be propagated up, without the alert being sent. Issued noted by tb@ ok tb@ --- src/lib/libssl/tls13_handshake.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libssl/tls13_handshake.c b/src/lib/libssl/tls13_handshake.c index d324a7f4ba..d739dc99e5 100644 --- a/src/lib/libssl/tls13_handshake.c +++ b/src/lib/libssl/tls13_handshake.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_handshake.c,v 1.55 2020/05/02 00:30:55 inoguchi Exp $ */ +/* $OpenBSD: tls13_handshake.c,v 1.56 2020/05/09 08:39:44 jsing Exp $ */ /* * Copyright (c) 2018-2019 Theo Buehler * Copyright (c) 2019 Joel Sing @@ -309,13 +309,16 @@ tls13_handshake_perform(struct tls13_ctx *ctx) if (ctx->alert) return tls13_send_alert(ctx->rl, ctx->alert); - if (action->sender == ctx->mode) { - if ((ret = tls13_handshake_send_action(ctx, action)) <= 0) - return ret; - } else { - if ((ret = tls13_handshake_recv_action(ctx, action)) <= 0) - return ret; - } + if (action->sender == ctx->mode) + ret = tls13_handshake_send_action(ctx, action); + else + ret = tls13_handshake_recv_action(ctx, action); + + if (ctx->alert) + return tls13_send_alert(ctx->rl, ctx->alert); + + if (ret <= 0) + return ret; if (!tls13_handshake_advance_state_machine(ctx)) return TLS13_IO_FAILURE; @@ -340,9 +343,6 @@ tls13_handshake_send_action(struct tls13_ctx *ctx, return TLS13_IO_FAILURE; if (!tls13_handshake_msg_finish(ctx->hs_msg)) return TLS13_IO_FAILURE; - - if (ctx->alert) - return tls13_send_alert(ctx->rl, ctx->alert); } if ((ret = tls13_handshake_msg_send(ctx->hs_msg, ctx->rl)) <= 0) @@ -424,9 +424,6 @@ tls13_handshake_recv_action(struct tls13_ctx *ctx, } } - if (ctx->alert) - ret = tls13_send_alert(ctx->rl, ctx->alert); - tls13_handshake_msg_free(ctx->hs_msg); ctx->hs_msg = NULL; -- cgit v1.2.3-55-g6feb