From: Ondrej Zajicek (work) Date: Thu, 3 May 2018 15:07:39 +0000 (+0200) Subject: Better initialization of random generator X-Git-Tag: v2.0.3~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eaf63d314d50cba5b2cfa8f18de64a91d3131b94;p=thirdparty%2Fbird.git Better initialization of random generator Use full time precision to initialize random generator. The old code was prone to initialize it to the same values in specific circumstances (boot without RTC, multiple VMs starting at once). --- diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 012deaf0a..11a0d6f17 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -2144,7 +2144,9 @@ io_init(void) // XXX init_times(); // XXX update_times(); boot_time = current_time(); - srandom((uint) (current_real_time() TO_S)); + + u64 now = (u64) current_real_time(); + srandom((uint) (now ^ (now >> 32))); } static int short_loops = 0;