Skip to content

Commit e1bd4dd

Browse files
authored
Merge pull request #7473 from douzzer/20240425-fixes
20240425-fixes
2 parents e414540 + 442d3f3 commit e1bd4dd

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

src/quic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,8 @@ const WOLFSSL_EVP_CIPHER* wolfSSL_quic_get_aead(WOLFSSL* ssl)
10131013
return evp_cipher;
10141014
}
10151015

1016-
static int evp_cipher_eq(const WOLFSSL_EVP_CIPHER* c1,
1016+
/* currently only used if HAVE_CHACHA && HAVE_POLY1305. */
1017+
WC_MAYBE_UNUSED static int evp_cipher_eq(const WOLFSSL_EVP_CIPHER* c1,
10171018
const WOLFSSL_EVP_CIPHER* c2)
10181019
{
10191020
/* We could check on nid equality, but we seem to have singulars */

src/ssl.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ int wc_OBJ_sn2nid(const char *sn)
289289

290290
#define HAVE_GLOBAL_RNG /* consolidate flags for using globalRNG */
291291
static WC_RNG globalRNG;
292-
static int initGlobalRNG = 0;
292+
static volatile int initGlobalRNG = 0;
293293

294294
static WC_MAYBE_UNUSED wolfSSL_Mutex globalRNGMutex
295295
WOLFSSL_MUTEX_INITIALIZER_CLAUSE(globalRNGMutex);
@@ -5758,11 +5758,13 @@ int wolfSSL_Init(void)
57585758
if (ret == WOLFSSL_SUCCESS) {
57595759
initRefCount++;
57605760
}
5761+
else {
5762+
initRefCount = 1; /* Force cleanup */
5763+
}
57615764

57625765
wc_UnLockMutex(&inits_count_mutex);
57635766

57645767
if (ret != WOLFSSL_SUCCESS) {
5765-
initRefCount = 1; /* Force cleanup */
57665768
(void)wolfSSL_Cleanup(); /* Ignore any error from cleanup */
57675769
}
57685770

@@ -23928,11 +23930,19 @@ int wolfSSL_RAND_bytes(unsigned char* buf, int num)
2392823930
WOLFSSL_MSG("Bad Lock Mutex rng");
2392923931
return ret;
2393023932
}
23931-
23932-
rng = &globalRNG;
23933-
used_global = 1;
23933+
/* the above access to initGlobalRNG is racey -- recheck it now that we
23934+
* have the lock.
23935+
*/
23936+
if (initGlobalRNG) {
23937+
rng = &globalRNG;
23938+
used_global = 1;
23939+
}
23940+
else {
23941+
wc_UnLockMutex(&globalRNGMutex);
23942+
}
2393423943
}
23935-
else
23944+
23945+
if (used_global == 0)
2393623946
#endif
2393723947
{
2393823948
#ifdef WOLFSSL_SMALL_STACK

wolfcrypt/test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38878,7 +38878,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t lms_test_verify_only(void)
3887838878
}
3887938879

3888038880
if (pub_len != HSS_MAX_PUBLIC_KEY_LEN) {
38881-
printf("error: LMS pub len %d, expected %d\n", pub_len,
38881+
printf("error: LMS pub len %u, expected %d\n", pub_len,
3888238882
HSS_MAX_PUBLIC_KEY_LEN);
3888338883
return WC_TEST_RET_ENC_EC(pub_len);
3888438884
}

0 commit comments

Comments
 (0)