mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
wolfssl-multi-test fixes:
- Remove RetrySendAlert and SendAlert recursion - args possible NULL dereference
This commit is contained in:
@@ -18579,13 +18579,14 @@ int BuildCertHashes(WOLFSSL* ssl, Hashes* hashes)
|
|||||||
#ifndef WOLFSSL_NO_TLS12
|
#ifndef WOLFSSL_NO_TLS12
|
||||||
void FreeBuildMsgArgs(WOLFSSL* ssl, BuildMsgArgs* args)
|
void FreeBuildMsgArgs(WOLFSSL* ssl, BuildMsgArgs* args)
|
||||||
{
|
{
|
||||||
|
(void)ssl;
|
||||||
if (args
|
if (args
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
&& ssl->options.buildArgsSet
|
&& ssl->options.buildArgsSet
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
/* only free the IV if it was dynamically allocated */
|
/* only free the IV if it was dynamically allocated */
|
||||||
if (ssl && args->iv && (args->iv != args->staticIvBuffer)) {
|
if (args->iv && (args->iv != args->staticIvBuffer)) {
|
||||||
XFREE(args->iv, ssl->heap, DYNAMIC_TYPE_SALT);
|
XFREE(args->iv, ssl->heap, DYNAMIC_TYPE_SALT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20597,22 +20598,7 @@ startScr:
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RetrySendAlert(WOLFSSL* ssl)
|
static int SendAlert_ex(WOLFSSL* ssl, int severity, int type)
|
||||||
{
|
|
||||||
int type = ssl->pendingAlert.code;
|
|
||||||
int severity = ssl->pendingAlert.level;
|
|
||||||
|
|
||||||
if (severity == alert_none)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ssl->pendingAlert.code = 0;
|
|
||||||
ssl->pendingAlert.level = alert_none;
|
|
||||||
|
|
||||||
return SendAlert(ssl, severity, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* send alert message */
|
|
||||||
int SendAlert(WOLFSSL* ssl, int severity, int type)
|
|
||||||
{
|
{
|
||||||
byte input[ALERT_SIZE];
|
byte input[ALERT_SIZE];
|
||||||
byte *output;
|
byte *output;
|
||||||
@@ -20643,21 +20629,6 @@ int SendAlert(WOLFSSL* ssl, int severity, int type)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ssl->pendingAlert.level != alert_none) {
|
|
||||||
ret = RetrySendAlert(ssl);
|
|
||||||
if (ret != 0) {
|
|
||||||
if (ssl->pendingAlert.level == alert_none ||
|
|
||||||
(ssl->pendingAlert.level != alert_fatal &&
|
|
||||||
severity == alert_fatal)) {
|
|
||||||
/* Store current alert if pendingAlert if free or if current
|
|
||||||
* is fatal and previous was not */
|
|
||||||
ssl->pendingAlert.code = type;
|
|
||||||
ssl->pendingAlert.level = severity;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ssl->pendingAlert.code = type;
|
ssl->pendingAlert.code = type;
|
||||||
ssl->pendingAlert.level = severity;
|
ssl->pendingAlert.level = severity;
|
||||||
|
|
||||||
@@ -20756,6 +20727,43 @@ int SendAlert(WOLFSSL* ssl, int severity, int type)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int RetrySendAlert(WOLFSSL* ssl)
|
||||||
|
{
|
||||||
|
int type = ssl->pendingAlert.code;
|
||||||
|
int severity = ssl->pendingAlert.level;
|
||||||
|
|
||||||
|
if (severity == alert_none)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ssl->pendingAlert.code = 0;
|
||||||
|
ssl->pendingAlert.level = alert_none;
|
||||||
|
|
||||||
|
return SendAlert_ex(ssl, severity, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send alert message */
|
||||||
|
int SendAlert(WOLFSSL* ssl, int severity, int type)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (ssl->pendingAlert.level != alert_none) {
|
||||||
|
ret = RetrySendAlert(ssl);
|
||||||
|
if (ret != 0) {
|
||||||
|
if (ssl->pendingAlert.level == alert_none ||
|
||||||
|
(ssl->pendingAlert.level != alert_fatal &&
|
||||||
|
severity == alert_fatal)) {
|
||||||
|
/* Store current alert if pendingAlert is empty or if current
|
||||||
|
* is fatal and previous was not */
|
||||||
|
ssl->pendingAlert.code = type;
|
||||||
|
ssl->pendingAlert.level = severity;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SendAlert_ex(ssl, severity, type);
|
||||||
|
}
|
||||||
|
|
||||||
const char* wolfSSL_ERR_reason_error_string(unsigned long e)
|
const char* wolfSSL_ERR_reason_error_string(unsigned long e)
|
||||||
{
|
{
|
||||||
#ifdef NO_ERROR_STRINGS
|
#ifdef NO_ERROR_STRINGS
|
||||||
@@ -29533,7 +29541,7 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
|
|||||||
#endif /* WOLFSSL_ASYNC_IO */
|
#endif /* WOLFSSL_ASYNC_IO */
|
||||||
|
|
||||||
/* Final cleanup */
|
/* Final cleanup */
|
||||||
if (args->input != NULL) {
|
if (args != NULL && args->input != NULL) {
|
||||||
XFREE(args->input, ssl->heap, DYNAMIC_TYPE_IN_BUFFER);
|
XFREE(args->input, ssl->heap, DYNAMIC_TYPE_IN_BUFFER);
|
||||||
args->input = NULL;
|
args->input = NULL;
|
||||||
}
|
}
|
||||||
|
@@ -4646,7 +4646,7 @@ static void FreeDch13Args(WOLFSSL* ssl, void* pArgs)
|
|||||||
|
|
||||||
(void)ssl;
|
(void)ssl;
|
||||||
|
|
||||||
if (args->clSuites) {
|
if (args && args->clSuites) {
|
||||||
XFREE(args->clSuites, ssl->heap, DYNAMIC_TYPE_SUITES);
|
XFREE(args->clSuites, ssl->heap, DYNAMIC_TYPE_SUITES);
|
||||||
args->clSuites = NULL;
|
args->clSuites = NULL;
|
||||||
}
|
}
|
||||||
@@ -6097,7 +6097,7 @@ static void FreeScv13Args(WOLFSSL* ssl, void* pArgs)
|
|||||||
|
|
||||||
(void)ssl;
|
(void)ssl;
|
||||||
|
|
||||||
if (args->sigData) {
|
if (args && args->sigData) {
|
||||||
XFREE(args->sigData, ssl->heap, DYNAMIC_TYPE_SIGNATURE);
|
XFREE(args->sigData, ssl->heap, DYNAMIC_TYPE_SIGNATURE);
|
||||||
args->sigData = NULL;
|
args->sigData = NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user