Skip to content

Commit

Permalink
Bug 1334413 - Don't try to seed from /dev/urandom in fuzzing mode r=f…
Browse files Browse the repository at this point in the history
…ranziskus

Differential Revision: https://nss-review.dev.mozaws.net/D179

--HG--
extra : amend_source : 62ca830db678672d7d744915ab3824975c389b04
  • Loading branch information
Tim Taubert committed Jan 27, 2017
1 parent 68c63a4 commit 95c4d05
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/freebl/drbg.c
Expand Up @@ -398,8 +398,10 @@ static PRStatus
rng_init(void)
{
PRUint8 bytes[PRNG_SEEDLEN * 2]; /* entropy + nonce */
#ifndef UNSAFE_FUZZER_MODE
unsigned int numBytes;
SECStatus rv = SECSuccess;
#endif

if (globalrng == NULL) {
/* bytes needs to have enough space to hold
Expand All @@ -416,6 +418,7 @@ rng_init(void)
return PR_FAILURE;
}

#ifndef UNSAFE_FUZZER_MODE
/* Try to get some seed data for the RNG */
numBytes = (unsigned int)RNG_SystemRNG(bytes, sizeof bytes);
PORT_Assert(numBytes == 0 || numBytes == sizeof bytes);
Expand All @@ -435,10 +438,11 @@ rng_init(void)
globalrng = NULL;
return PR_FAILURE;
}

if (rv != SECSuccess) {
return PR_FAILURE;
}
#endif

/* the RNG is in a valid state */
globalrng->isValid = PR_TRUE;

Expand Down

0 comments on commit 95c4d05

Please sign in to comment.