Skip to content

Commit 5f387e9

Browse files
committed
dtls13: always remove CH from the RTX after SH/HRR message
1 parent 20a667c commit 5f387e9

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/dtls13.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ static void Dtls13RtxRemoveCurAck(WOLFSSL* ssl)
897897
#endif
898898
}
899899

900-
static void Dtls13MaybeSaveClientHello(WOLFSSL* ssl)
900+
static void Dtls13SaveOrFlushClientHello(WOLFSSL* ssl)
901901
{
902902
Dtls13RtxRecord *r, **prev_next;
903903

@@ -906,15 +906,18 @@ static void Dtls13MaybeSaveClientHello(WOLFSSL* ssl)
906906

907907
if (ssl->options.side == WOLFSSL_CLIENT_END &&
908908
ssl->options.connectState >= CLIENT_HELLO_SENT &&
909-
ssl->options.connectState <= HELLO_AGAIN_REPLY &&
910-
ssl->options.downgrade && ssl->options.minDowngrade >= DTLSv1_2_MINOR) {
909+
ssl->options.connectState <= HELLO_AGAIN_REPLY) {
911910
while (r != NULL) {
912911
if (r->handshakeType == client_hello) {
913912
Dtls13RtxRecordUnlink(ssl, prev_next, r);
914-
XFREE(ssl->dtls13ClientHello, ssl->heap, DYNAMIC_TYPE_DTLS_MSG);
915-
ssl->dtls13ClientHello = r->data;
916-
ssl->dtls13ClientHelloSz = r->length;
917-
r->data = NULL;
913+
if (ssl->options.downgrade &&
914+
ssl->options.minDowngrade >= DTLSv1_2_MINOR) {
915+
XFREE(ssl->dtls13ClientHello, ssl->heap,
916+
DYNAMIC_TYPE_DTLS_MSG);
917+
ssl->dtls13ClientHello = r->data;
918+
ssl->dtls13ClientHelloSz = r->length;
919+
r->data = NULL;
920+
}
918921
Dtls13FreeRtxBufferRecord(ssl, r);
919922
return;
920923
}
@@ -934,7 +937,7 @@ static int Dtls13RtxMsgRecvd(WOLFSSL* ssl, enum HandShakeType hs,
934937
ssl->keys.dtls_expected_peer_handshake_number) {
935938

936939
if (hs == server_hello)
937-
Dtls13MaybeSaveClientHello(ssl);
940+
Dtls13SaveOrFlushClientHello(ssl);
938941

939942
/* In the handshake, receiving part of the next flight, acknowledge the
940943
* sent flight. */

0 commit comments

Comments
 (0)