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

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

Issue 15990009: Call abort() if NSS cannot read from /dev/urandom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: 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') | patches/nss-urandom-abort.patch » ('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 204056)
+++ nss/lib/freebl/unix_rand.c (working copy)
@@ -918,6 +918,16 @@
|| defined(HPUX)
if (bytes)
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 failed to read from /dev/urandom. "
+ "Abort process.\n", __FILE__, __LINE__);
+ fflush(stderr);
+ abort();
#endif
#ifdef SOLARIS
@@ -968,9 +978,8 @@
/* suppress valgrind warnings due to holes in struct stat */
memset(&stat_buf, 0, sizeof(stat_buf));
- if (stat((char *)fileName, &stat_buf) < 0)
- return fileBytes;
- RNG_RandomUpdate(&stat_buf, sizeof(stat_buf));
+ if (stat((char *)fileName, &stat_buf) == 0)
+ RNG_RandomUpdate(&stat_buf, sizeof(stat_buf));
wtc 2013/06/10 19:39:37 This change is required only if we don't have the
file = fopen((char *)fileName, "r");
if (file != NULL) {
@@ -1132,7 +1141,15 @@
file = fopen("/dev/urandom", "r");
if (file == NULL) {
- return rng_systemFromNoise(dest, maxLen);
+ /*
+ * 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);
+ abort();
}
while (maxLen > fileBytes) {
bytes = maxLen - fileBytes;
« no previous file with comments | « README.chromium ('k') | patches/nss-urandom-abort.patch » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698