mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 03:07:29 +02:00
Merge pull request #5364 from embhorn/zd14519
Fix wolfSSL_Init error handling
This commit is contained in:
23
src/ssl.c
23
src/ssl.c
@ -5479,13 +5479,15 @@ int wolfSSL_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_GLOBAL_RNG
|
#ifdef HAVE_GLOBAL_RNG
|
||||||
if ((ret == WOLFSSL_SUCCESS) && (wc_InitMutex(&globalRNGMutex) != 0)) {
|
if (ret == WOLFSSL_SUCCESS) {
|
||||||
|
if (wc_InitMutex(&globalRNGMutex) != 0) {
|
||||||
WOLFSSL_MSG("Bad Init Mutex rng");
|
WOLFSSL_MSG("Bad Init Mutex rng");
|
||||||
ret = BAD_MUTEX_E;
|
ret = BAD_MUTEX_E;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
globalRNGMutex_valid = 1;
|
globalRNGMutex_valid = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WC_RNG_SEED_CB
|
#ifdef WC_RNG_SEED_CB
|
||||||
@ -5520,33 +5522,37 @@ int wolfSSL_Init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((ret == WOLFSSL_SUCCESS) && (wc_InitMutex(&session_mutex) != 0)) {
|
if (ret == WOLFSSL_SUCCESS) {
|
||||||
|
if (wc_InitMutex(&session_mutex) != 0) {
|
||||||
WOLFSSL_MSG("Bad Init Mutex session");
|
WOLFSSL_MSG("Bad Init Mutex session");
|
||||||
ret = BAD_MUTEX_E;
|
ret = BAD_MUTEX_E;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
session_mutex_valid = 1;
|
session_mutex_valid = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifndef NO_CLIENT_CACHE
|
#ifndef NO_CLIENT_CACHE
|
||||||
if ((ret == WOLFSSL_SUCCESS) &&
|
if (ret == WOLFSSL_SUCCESS) {
|
||||||
(wc_InitMutex(&clisession_mutex) != 0)) {
|
if (wc_InitMutex(&clisession_mutex) != 0) {
|
||||||
WOLFSSL_MSG("Bad Init Mutex session");
|
WOLFSSL_MSG("Bad Init Mutex session");
|
||||||
ret = BAD_MUTEX_E;
|
ret = BAD_MUTEX_E;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clisession_mutex_valid = 1;
|
clisession_mutex_valid = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if ((ret == WOLFSSL_SUCCESS) && (wc_InitMutex(&count_mutex) != 0)) {
|
if (ret == WOLFSSL_SUCCESS) {
|
||||||
|
if (wc_InitMutex(&count_mutex) != 0) {
|
||||||
WOLFSSL_MSG("Bad Init Mutex count");
|
WOLFSSL_MSG("Bad Init Mutex count");
|
||||||
ret = BAD_MUTEX_E;
|
ret = BAD_MUTEX_E;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
count_mutex_valid = 1;
|
count_mutex_valid = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#if defined(OPENSSL_EXTRA) && defined(HAVE_ATEXIT)
|
#if defined(OPENSSL_EXTRA) && defined(HAVE_ATEXIT)
|
||||||
/* OpenSSL registers cleanup using atexit */
|
/* OpenSSL registers cleanup using atexit */
|
||||||
if ((ret == WOLFSSL_SUCCESS) && (atexit(AtExitCleanup) != 0)) {
|
if ((ret == WOLFSSL_SUCCESS) && (atexit(AtExitCleanup) != 0)) {
|
||||||
@ -5556,7 +5562,8 @@ int wolfSSL_Init(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret == WOLFSSL_SUCCESS) && (wc_LockMutex(&count_mutex) != 0)) {
|
if (ret == WOLFSSL_SUCCESS) {
|
||||||
|
if (wc_LockMutex(&count_mutex) != 0) {
|
||||||
WOLFSSL_MSG("Bad Lock Mutex count");
|
WOLFSSL_MSG("Bad Lock Mutex count");
|
||||||
ret = BAD_MUTEX_E;
|
ret = BAD_MUTEX_E;
|
||||||
}
|
}
|
||||||
@ -5564,6 +5571,7 @@ int wolfSSL_Init(void)
|
|||||||
initRefCount++;
|
initRefCount++;
|
||||||
wc_UnLockMutex(&count_mutex);
|
wc_UnLockMutex(&count_mutex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ret != WOLFSSL_SUCCESS) {
|
if (ret != WOLFSSL_SUCCESS) {
|
||||||
initRefCount = 1; /* Force cleanup */
|
initRefCount = 1; /* Force cleanup */
|
||||||
@ -5574,7 +5582,6 @@ int wolfSSL_Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_CERTS
|
#ifndef NO_CERTS
|
||||||
|
|
||||||
/* process user cert chain to pass during the handshake */
|
/* process user cert chain to pass during the handshake */
|
||||||
|
Reference in New Issue
Block a user