SendAlert: clear output buffer to try and send the alert now

This commit is contained in:
Juliusz Sosinowicz 2022-06-01 16:48:57 +02:00
parent df10e1fad2
commit d29c656d4f

View File

@ -20640,8 +20640,25 @@ int SendAlert(WOLFSSL* ssl, int severity, int type)
/* check for available size */
outputSz = ALERT_SIZE + MAX_MSG_EXTRA + dtlsExtra;
if ((ret = CheckAvailableSize(ssl, outputSz)) != 0)
if ((ret = CheckAvailableSize(ssl, outputSz)) != 0) {
#ifdef WOLFSSL_DTLS
/* If CheckAvailableSize returned WANT_WRITE due to a blocking write
* then discard pending output and just send the alert. */
if (ssl->options.dtls) {
if (ret != WANT_WRITE || severity != alert_fatal)
return ret;
ShrinkOutputBuffer(ssl);
if ((ret = CheckAvailableSize(ssl, outputSz)) != 0) {
return ret;
}
}
else {
return ret;
}
#else
return ret;
#endif
}
/* Check output buffer */
if (ssl->buffers.outputBuffer.buffer == NULL)