diff options
author | wtc%google.com <devnull@localhost> | 2008-10-07 21:45:09 +0000 |
---|---|---|
committer | wtc%google.com <devnull@localhost> | 2008-10-07 21:45:09 +0000 |
commit | 94833b11a0baf7b967c18b2654b3cb5cce45db81 (patch) | |
tree | ea135827aebaca0d14dc73f030bbd65f780cf07e | |
parent | 9cb0106c858de785d44202df6ed5a100d644104a (diff) | |
download | nspr-hg-94833b11a0baf7b967c18b2654b3cb5cce45db81.tar.gz |
Bug 455829: read from /dev/urandom instead of /dev/random because
/dev/random may block for a long time. The patch is contributed by
Mike Hommey <mh+mozilla@glandium.org>. r=wtc.
-rw-r--r-- | pr/src/md/unix/uxrng.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/pr/src/md/unix/uxrng.c b/pr/src/md/unix/uxrng.c index a5355fdf..86f07825 100644 --- a/pr/src/md/unix/uxrng.c +++ b/pr/src/md/unix/uxrng.c @@ -145,39 +145,39 @@ GetHighResClock(void *buf, size_t maxbytes) #include <sys/stat.h> #include <fcntl.h> -static int fdDevRandom; -static PRCallOnceType coOpenDevRandom; +static int fdDevURandom; +static PRCallOnceType coOpenDevURandom; -static PRStatus OpenDevRandom( void ) +static PRStatus OpenDevURandom( void ) { - fdDevRandom = open( "/dev/random", O_RDONLY ); - return((-1 == fdDevRandom)? PR_FAILURE : PR_SUCCESS ); -} /* end OpenDevRandom() */ + fdDevURandom = open( "/dev/urandom", O_RDONLY ); + return((-1 == fdDevURandom)? PR_FAILURE : PR_SUCCESS ); +} /* end OpenDevURandom() */ -static size_t GetDevRandom( void *buf, size_t size ) +static size_t GetDevURandom( void *buf, size_t size ) { int bytesIn; int rc; - rc = PR_CallOnce( &coOpenDevRandom, OpenDevRandom ); + rc = PR_CallOnce( &coOpenDevURandom, OpenDevURandom ); if ( PR_FAILURE == rc ) { _PR_MD_MAP_OPEN_ERROR( errno ); return(0); } - bytesIn = read( fdDevRandom, buf, size ); + bytesIn = read( fdDevURandom, buf, size ); if ( -1 == bytesIn ) { _PR_MD_MAP_READ_ERROR( errno ); return(0); } return( bytesIn ); -} /* end GetDevRandom() */ +} /* end GetDevURandom() */ static size_t GetHighResClock(void *buf, size_t maxbytes) { - return(GetDevRandom( buf, maxbytes )); + return(GetDevURandom( buf, maxbytes )); } #elif defined(NCR) |