From 6e3c3577f5943cac2988d3547894848309c549db Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Thu, 24 Aug 2023 19:24:40 +0200 Subject: [PATCH] Refactor the crazy conditional in VerifyForDtlsMsgPoolSend --- src/internal.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/internal.c b/src/internal.c index f74b96726..2233635f5 100644 --- a/src/internal.c +++ b/src/internal.c @@ -9199,13 +9199,21 @@ int VerifyForDtlsMsgPoolSend(WOLFSSL* ssl, byte type, word32 fragOffset) * to be used for triggering retransmission of whole DtlsMsgPool. * change cipher suite type is not verified here */ - return ((fragOffset == 0) && - (((ssl->options.side == WOLFSSL_SERVER_END) && - ((type == client_hello) || - ((ssl->options.verifyPeer) && (type == certificate)) || - ((!ssl->options.verifyPeer) && (type == client_key_exchange)))) || - ((ssl->options.side == WOLFSSL_CLIENT_END) && - (type == hello_request || type == server_hello)))); + if (fragOffset == 0) { + if (ssl->options.side == WOLFSSL_SERVER_END) { + if (type == client_hello) + return 1; + else if (ssl->options.verifyPeer && type == certificate) + return 1; + else if (!ssl->options.verifyPeer && type == client_key_exchange) + return 1; + } + else { + if (type == hello_request || type == server_hello) + return 1; + } + } + return 0; }