dovecot-2.0: lib_init(): Call srand() with a bit better seed.
dovecot at dovecot.org
dovecot at dovecot.org
Fri Dec 3 00:59:45 EET 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/8e30a07d8dd0
changeset: 12492:8e30a07d8dd0
user: Timo Sirainen <tss at iki.fi>
date: Thu Dec 02 22:59:42 2010 +0000
description:
lib_init(): Call srand() with a bit better seed.
diffstat:
src/lib/lib.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diffs (27 lines):
diff -r 6c9bc37fcf41 -r 8e30a07d8dd0 src/lib/lib.c
--- a/src/lib/lib.c Thu Dec 02 21:42:30 2010 +0000
+++ b/src/lib/lib.c Thu Dec 02 22:59:42 2010 +0000
@@ -6,7 +6,8 @@
#include "process-title.h"
#include <stdlib.h>
-#include <time.h>
+#include <unistd.h>
+#include <sys/time.h>
size_t nearest_power(size_t num)
{
@@ -20,8 +21,12 @@
void lib_init(void)
{
+ struct timeval tv;
+
/* standard way to get rand() return different values. */
- srand((unsigned int) time(NULL));
+ if (gettimeofday(&tv, NULL) < 0)
+ i_fatal("gettimeofday(): %m");
+ srand((unsigned int) (tv.tv_sec ^ tv.tv_usec ^ getpid()));
data_stack_init();
hostpid_init();
More information about the dovecot-cvs
mailing list