Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: nss/lib/freebl/unix_rand.c

Issue 17058006: RNG_SystemRNG should fail rather than falling back on rng_systemFromNoise (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Use zu to print size_t Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « README.chromium ('k') | nss/lib/freebl/win_rand.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: nss/lib/freebl/unix_rand.c
===================================================================
--- nss/lib/freebl/unix_rand.c (revision 206814)
+++ nss/lib/freebl/unix_rand.c (working copy)
@@ -916,7 +916,7 @@
#if defined(BSDI) || defined(FREEBSD) || defined(NETBSD) \
|| defined(OPENBSD) || defined(DARWIN) || defined(LINUX) \
|| defined(HPUX)
- if (bytes)
+ if (bytes == SYSTEM_RNG_SEED_COUNT)
return;
/*
@@ -924,8 +924,9 @@
*
* See crbug.com/244661 for details.
*/
- fprintf(stderr, "[ERROR:%s(%d)] NSS failed to read from /dev/urandom. "
- "Abort process.\n", __FILE__, __LINE__);
+ 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
@@ -1133,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;
@@ -1142,11 +1148,6 @@
file = fopen("/dev/urandom", "r");
if (file == NULL) {
- /*
- * 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 failed to read from /dev/urandom. "
"Abort process.\n", __FILE__, __LINE__);
fflush(stderr);
@@ -1162,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;
}
« no previous file with comments | « README.chromium ('k') | nss/lib/freebl/win_rand.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698