diff options
author | Wan-Teh Chang <wtc@google.com> | 2013-12-04 12:21:25 -0800 |
---|---|---|
committer | Wan-Teh Chang <wtc@google.com> | 2013-12-04 12:21:25 -0800 |
commit | 3d00d2b1ab1d8a1d1db1c9d7af2a5fd39f54aac2 (patch) | |
tree | c24a67c39f2daa490cc5d1fff7e7a95ea16a07de | |
parent | c995b7acefab29edcf0cf193f78e693d56cee7e0 (diff) | |
download | nss-hg-3d00d2b1ab1d8a1d1db1c9d7af2a5fd39f54aac2.tar.gz |
Bug 935831: Assert that fileno() on a newly opened FILE object doesn't
fail. r=brian.
-rw-r--r-- | lib/freebl/unix_rand.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/freebl/unix_rand.c b/lib/freebl/unix_rand.c index b8a1092aa..579040eea 100644 --- a/lib/freebl/unix_rand.c +++ b/lib/freebl/unix_rand.c @@ -983,6 +983,8 @@ size_t RNG_FileUpdate(const char *fileName, size_t limit) * Moreover, we read into a buffer of size BUFSIZ, so buffered I/O * has no performance advantage. */ fd = fileno(file); + /* 'file' was just opened, so this should not fail. */ + PORT_Assert(fd != -1); while (limit > fileBytes) { bytes = PR_MIN(sizeof buffer, limit - fileBytes); bytes = read(fd, buffer, bytes); @@ -1150,6 +1152,8 @@ size_t RNG_SystemRNG(void *dest, size_t maxLen) * EOF in unbuffered I/O mode on Android. */ fd = fileno(file); + /* 'file' was just opened, so this should not fail. */ + PORT_Assert(fd != -1); while (maxLen > fileBytes) { bytes = maxLen - fileBytes; bytes = read(fd, buffer, bytes); |