Bug 935831 - Back out Bug 927230 for Android 2.3 startup crash, r=briansmith

--HG--
extra : rebase_source : 5b8ff8da93a882d6c8303c26d234ad63b748389c
This commit is contained in:
Richard Newman 2013-11-20 17:05:55 -08:00
parent ee410db68b
commit 265a98b711
4 changed files with 51 additions and 8 deletions

View File

@ -10,4 +10,3 @@
*/
#error "Do not include this header file."

View File

@ -974,10 +974,6 @@ size_t RNG_FileUpdate(const char *fileName, size_t limit)
file = fopen(fileName, "r");
if (file != NULL) {
/* Set buffering mode to unbuffered I/O to avoid reading more bytes
* than we need from /dev/urandom. Moreover, we read into a buffer
* of size BUFSIZ, so buffered I/O has no performance advantage. */
setvbuf(file, NULL, _IONBF, 0);
while (limit > fileBytes) {
bytes = PR_MIN(sizeof buffer, limit - fileBytes);
bytes = fread(buffer, 1, bytes, file);
@ -1138,9 +1134,6 @@ size_t RNG_SystemRNG(void *dest, size_t maxLen)
if (file == NULL) {
return rng_systemFromNoise(dest, maxLen);
}
/* Set buffering mode to unbuffered I/O to avoid reading more bytes
* than we need from /dev/urandom. */
setvbuf(file, NULL, _IONBF, 0);
while (maxLen > fileBytes) {
bytes = maxLen - fileBytes;
bytes = fread(buffer, 1, bytes, file);

View File

@ -1,3 +1,4 @@
This directory contains patches that were added locally
on top of the NSS release.
bug-935831.patch Backout the fix for bug 927230.

View File

@ -0,0 +1,50 @@
# HG changeset patch
# Parent cb500491e8a524edb44213d1a787adb98c385ecd
# User Richard Newman <rnewman@mozilla.com>
Back out Bug 927230 for Android 2.3 startup crash. r=briansmith
diff --git a/security/nss/lib/freebl/unix_rand.c b/security/nss/lib/freebl/unix_rand.c
--- a/security/nss/lib/freebl/unix_rand.c
+++ b/security/nss/lib/freebl/unix_rand.c
@@ -969,20 +969,16 @@ size_t RNG_FileUpdate(const char *fileNa
memset(&stat_buf, 0, sizeof(stat_buf));
if (stat((char *)fileName, &stat_buf) < 0)
return fileBytes;
RNG_RandomUpdate(&stat_buf, sizeof(stat_buf));
file = fopen(fileName, "r");
if (file != NULL) {
- /* Set buffering mode to unbuffered I/O to avoid reading more bytes
- * than we need from /dev/urandom. Moreover, we read into a buffer
- * of size BUFSIZ, so buffered I/O has no performance advantage. */
- setvbuf(file, NULL, _IONBF, 0);
while (limit > fileBytes) {
bytes = PR_MIN(sizeof buffer, limit - fileBytes);
bytes = fread(buffer, 1, bytes, file);
if (bytes == 0)
break;
RNG_RandomUpdate(buffer, bytes);
fileBytes += bytes;
totalFileBytes += bytes;
@@ -1133,19 +1129,16 @@ size_t RNG_SystemRNG(void *dest, size_t
size_t bytes;
size_t fileBytes = 0;
unsigned char *buffer = dest;
file = fopen("/dev/urandom", "r");
if (file == NULL) {
return rng_systemFromNoise(dest, maxLen);
}
- /* Set buffering mode to unbuffered I/O to avoid reading more bytes
- * than we need from /dev/urandom. */
- setvbuf(file, NULL, _IONBF, 0);
while (maxLen > fileBytes) {
bytes = maxLen - fileBytes;
bytes = fread(buffer, 1, bytes, file);
if (bytes == 0)
break;
fileBytes += bytes;
buffer += bytes;
}