Merge pull request #5408 from julek-wolfssl/FreeAsyncCtx-location

FreeAsyncCtx should only be called when advancing state
This commit is contained in:
David Garske
2022-07-27 09:59:28 -07:00
committed by GitHub
2 changed files with 34 additions and 36 deletions

View File

@ -11908,12 +11908,12 @@ int wolfSSL_DTLS_SetCookieSecret(WOLFSSL* ssl,
ssl->options.connectState++; ssl->options.connectState++;
WOLFSSL_MSG("connect state: " WOLFSSL_MSG("connect state: "
"Advanced from last buffered fragment send"); "Advanced from last buffered fragment send");
}
#ifdef WOLFSSL_ASYNC_IO #ifdef WOLFSSL_ASYNC_IO
/* Cleanup async */ /* Cleanup async */
FreeAsyncCtx(ssl, 0); FreeAsyncCtx(ssl, 0);
#endif #endif
} }
}
else { else {
WOLFSSL_MSG("connect state: " WOLFSSL_MSG("connect state: "
"Not advanced, more fragments to send"); "Not advanced, more fragments to send");
@ -12438,12 +12438,12 @@ int wolfSSL_DTLS_SetCookieSecret(WOLFSSL* ssl,
ssl->options.acceptState++; ssl->options.acceptState++;
WOLFSSL_MSG("accept state: " WOLFSSL_MSG("accept state: "
"Advanced from last buffered fragment send"); "Advanced from last buffered fragment send");
}
#ifdef WOLFSSL_ASYNC_IO #ifdef WOLFSSL_ASYNC_IO
/* Cleanup async */ /* Cleanup async */
FreeAsyncCtx(ssl, 0); FreeAsyncCtx(ssl, 0);
#endif #endif
} }
}
else { else {
WOLFSSL_MSG("accept state: " WOLFSSL_MSG("accept state: "
"Not advanced, more fragments to send"); "Not advanced, more fragments to send");

View File

@ -8262,9 +8262,9 @@ static int SendTls13KeyUpdate(WOLFSSL* ssl)
OPAQUE8_LEN + Dtls13GetRlHeaderLength(1) + DTLS_HANDSHAKE_HEADER_SZ, OPAQUE8_LEN + Dtls13GetRlHeaderLength(1) + DTLS_HANDSHAKE_HEADER_SZ,
key_update, 0); key_update, 0);
} }
else { else
#endif /* WOLFSSL_DTLS13 */ #endif /* WOLFSSL_DTLS13 */
{
/* This message is always encrypted. */ /* This message is always encrypted. */
sendSz = BuildTls13Message(ssl, output, outputSz, input, sendSz = BuildTls13Message(ssl, output, outputSz, input,
headerSz + OPAQUE8_LEN, handshake, 0, 0, 0); headerSz + OPAQUE8_LEN, handshake, 0, 0, 0);
@ -8286,9 +8286,7 @@ static int SendTls13KeyUpdate(WOLFSSL* ssl)
if (ret != 0 && ret != WANT_WRITE) if (ret != 0 && ret != WANT_WRITE)
return ret; return ret;
#ifdef WOLFSSL_DTLS13
} }
#endif /* WOLFSSL_DTLS13 */
/* In DTLS we must wait for the ack before setting up the new keys */ /* In DTLS we must wait for the ack before setting up the new keys */
if (!ssl->options.dtls) { if (!ssl->options.dtls) {
@ -9801,16 +9799,16 @@ int wolfSSL_connect_TLSv13(WOLFSSL* ssl)
} }
WOLFSSL_MSG("connect state: " WOLFSSL_MSG("connect state: "
"Advanced from last buffered fragment send"); "Advanced from last buffered fragment send");
#ifdef WOLFSSL_ASYNC_IO
FreeAsyncCtx(ssl, 0);
#endif
} }
} }
else { else {
WOLFSSL_MSG("connect state: " WOLFSSL_MSG("connect state: "
"Not advanced, more fragments to send"); "Not advanced, more fragments to send");
} }
#ifdef WOLFSSL_ASYNC_IO
FreeAsyncCtx(ssl, 0);
#endif
#ifdef WOLFSSL_DTLS13 #ifdef WOLFSSL_DTLS13
if (ssl->options.dtls) if (ssl->options.dtls)
ssl->dtls13SendingAckOrRtx =0; ssl->dtls13SendingAckOrRtx =0;
@ -10878,10 +10876,10 @@ int wolfSSL_accept_TLSv13(WOLFSSL* ssl)
ssl->options.acceptState++; ssl->options.acceptState++;
WOLFSSL_MSG("accept state: " WOLFSSL_MSG("accept state: "
"Advanced from last buffered fragment send"); "Advanced from last buffered fragment send");
} #ifdef WOLFSSL_ASYNC_IO
#ifdef WOLFSSL_ASYNC_IO
FreeAsyncCtx(ssl, 0); FreeAsyncCtx(ssl, 0);
#endif #endif
}
} }
else { else {
WOLFSSL_MSG("accept state: " WOLFSSL_MSG("accept state: "