Skip to content

Commit 0420c94

Browse files
Only use -1 for uninitialized fds as 0 is a valid fd.
1 parent 2e83b97 commit 0420c94

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

wolfcrypt/src/random.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ static int _InitRng(WC_RNG* rng, byte* nonce, word32 nonceSz,
895895
#endif
896896

897897
#ifndef USE_WINDOWS_API
898-
rng->seed.fd = 0;
898+
rng->seed.fd = -1;
899899
#endif
900900

901901
#ifdef CUSTOM_RAND_GENERATE_BLOCK
@@ -1378,7 +1378,7 @@ int wc_FreeRng(WC_RNG* rng)
13781378
#endif
13791379

13801380
#ifdef XCLOSE
1381-
if(rng->seed.fd != 0 && rng->seed.fd != -1) {
1381+
if(rng->seed.fd != -1) {
13821382
XCLOSE(rng->seed.fd);
13831383
rng->seed.fd = -1;
13841384
}
@@ -3564,7 +3564,7 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
35643564

35653565
#ifndef NO_FILESYSTEM
35663566
#ifndef NO_DEV_URANDOM /* way to disable use of /dev/urandom */
3567-
if (os->fd == 0 || os->fd == -1) {
3567+
if (os->fd == -1) {
35683568
os->fd = open("/dev/urandom", O_RDONLY);
35693569
#if defined(DEBUG_WOLFSSL)
35703570
WOLFSSL_MSG("opened /dev/urandom.");

0 commit comments

Comments
 (0)