Skip to content

Commit c809605

Browse files
authored
Merge pull request #191 from haydenroche5/rand_checks
Add some missing return value checks in we_rand_bytes.
2 parents e4a88b3 + 034fb37 commit c809605

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/we_random.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ static int we_rand_bytes(unsigned char *buf, int num)
362362
rc = wc_LockMutex(we_rng_mutex);
363363
if (rc != 0) {
364364
WOLFENGINE_ERROR_FUNC(WE_LOG_RNG, "wc_LockMutex", rc);
365+
ret = 0;
365366
}
366367
else
367368
#endif
@@ -374,7 +375,7 @@ static int we_rand_bytes(unsigned char *buf, int num)
374375
}
375376
#ifndef WE_STATIC_WOLFSSL
376377
/* Mix global seed if RAND_add() or RAND_seed() has been called. */
377-
if (haveSeed) {
378+
if (ret == 1 && haveSeed) {
378379
ret = we_rand_mix_seed(buf, num, we_seed, sizeof(we_seed));
379380
if (ret != 1) {
380381
WOLFENGINE_ERROR_MSG(WE_LOG_RNG, "we_rand_mix_seed with global "

0 commit comments

Comments
 (0)