From: Timo Sirainen Date: Thu, 2 Dec 2010 22:59:42 +0000 (+0000) Subject: lib_init(): Call srand() with a bit better seed. X-Git-Tag: 2.0.8~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0b47e0098e8510b2e36a38036c88e64882c9f874;p=thirdparty%2Fdovecot%2Fcore.git lib_init(): Call srand() with a bit better seed. --- diff --git a/src/lib/lib.c b/src/lib/lib.c index bb832e7dd0..b9d87c7c8a 100644 --- a/src/lib/lib.c +++ b/src/lib/lib.c @@ -6,7 +6,8 @@ #include "process-title.h" #include -#include +#include +#include size_t nearest_power(size_t num) { @@ -20,8 +21,12 @@ size_t nearest_power(size_t num) 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();