refactor: new define to remove some preprocessor directives

This commit is contained in:
Marco Oliverio
2022-08-30 08:55:24 +02:00
parent 43715d1bb5
commit 655ac3e822
4 changed files with 10 additions and 30 deletions

View File

@ -10400,13 +10400,8 @@ static int GetRecordHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
else {
WOLFSSL_MSG("SSL version error");
/* send alert per RFC5246 Appendix E. Backward Compatibility */
if (ssl->options.side == WOLFSSL_CLIENT_END) {
#ifdef WOLFSSL_MYSQL_COMPATIBLE
SendAlert(ssl, alert_fatal, wc_protocol_version);
#else
SendAlert(ssl, alert_fatal, protocol_version);
#endif
}
if (ssl->options.side == WOLFSSL_CLIENT_END)
SendAlert(ssl, alert_fatal, wolfssl_alert_protocol_version);
WOLFSSL_ERROR_VERBOSE(VERSION_ERROR);
return VERSION_ERROR; /* only use requested version */
}
@ -18471,24 +18466,12 @@ const char* AlertTypeToString(int type)
return decrypt_error_str;
}
#ifdef WOLFSSL_MYSQL_COMPATIBLE
/* catch name conflict for enum protocol with MYSQL build */
case wc_protocol_version:
{
static const char wc_protocol_version_str[] =
"wc_protocol_version";
return wc_protocol_version_str;
}
#else
case protocol_version:
case wolfssl_alert_protocol_version:
{
static const char protocol_version_str[] =
"protocol_version";
return protocol_version_str;
}
#endif
case insufficient_security:
{
static const char insufficient_security_str[] =

View File

@ -6038,11 +6038,7 @@ static int TLSX_SupportedVersions_Parse(WOLFSSL* ssl, const byte* input,
set = 1;
}
if (!set) {
#ifdef WOLFSSL_MYSQL_COMPATIBLE
SendAlert(ssl, alert_fatal, wc_protocol_version);
#else
SendAlert(ssl, alert_fatal, protocol_version);
#endif
SendAlert(ssl, alert_fatal, wolfssl_alert_protocol_version);
WOLFSSL_ERROR_VERBOSE(VERSION_ERROR);
return VERSION_ERROR;
}

View File

@ -5671,11 +5671,7 @@ int DoTls13ClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
/* this check pass for DTLS Major (0xff) */
if (args->pv.major < SSLv3_MAJOR) {
WOLFSSL_MSG("Legacy version field contains unsupported value");
#ifdef WOLFSSL_MYSQL_COMPATIBLE
SendAlert(ssl, alert_fatal, wc_protocol_version);
#else
SendAlert(ssl, alert_fatal, protocol_version);
#endif
SendAlert(ssl, alert_fatal, wolfssl_alert_protocol_version);
ERROR_OUT(INVALID_PARAMETER, exit_dch);
}

View File

@ -768,6 +768,11 @@ enum AlertDescription {
no_application_protocol = 120
};
#ifdef WOLFSSL_MYSQL_COMPATIBLE
#define wolfssl_alert_protocol_version wc_protocol_version
#else
#define wolfssl_alert_protocol_version protocol_version
#endif
enum AlertLevel {
alert_none = 0, /* Used to indicate no alert level is set */