Index: unix_rand.c =================================================================== --- unix_rand.c (revision 203531) +++ unix_rand.c (working copy) @@ -916,8 +916,19 @@ #if defined(BSDI) || defined(FREEBSD) || defined(NETBSD) \ || defined(OPENBSD) || defined(DARWIN) || defined(LINUX) \ || defined(HPUX) - if (bytes) + if (bytes == SYSTEM_RNG_SEED_COUNT) return; + + /* + * Modified to abort the process if it failed to read from /dev/urandom. + * + * See crbug.com/244661 for details. + */ + fprintf(stderr, "[ERROR:%s(%d)] NSS read %zu bytes (expected %d bytes) " + "from /dev/urandom. Abort process.\n", __FILE__, __LINE__, + bytes, SYSTEM_RNG_SEED_COUNT); + fflush(stderr); + abort(); #endif #ifdef SOLARIS @@ -1123,6 +1134,11 @@ } } +/* + * Modified to abort the process if it failed to read from /dev/urandom. + * + * See crbug.com/244661 for details. + */ size_t RNG_SystemRNG(void *dest, size_t maxLen) { FILE *file; @@ -1132,7 +1148,10 @@ file = fopen("/dev/urandom", "r"); if (file == NULL) { - return rng_systemFromNoise(dest, maxLen); + fprintf(stderr, "[ERROR:%s(%d)] NSS failed to read from /dev/urandom. " + "Abort process.\n", __FILE__, __LINE__); + fflush(stderr); + abort(); } while (maxLen > fileBytes) { bytes = maxLen - fileBytes; @@ -1144,8 +1163,10 @@ } fclose(file); if (fileBytes != maxLen) { - PORT_SetError(SEC_ERROR_NEED_RANDOM); /* system RNG failed */ - fileBytes = 0; + fprintf(stderr, "[ERROR:%s(%d)] NSS failed to read from /dev/urandom. " + "Abort process.\n", __FILE__, __LINE__); + fflush(stderr); + abort(); } return fileBytes; }