bird2: Add package
[feed/routing.git] / bird2 / patches / 0005-Better-initialization-of-random-generator.patch
1 From eaf63d314d50cba5b2cfa8f18de64a91d3131b94 Mon Sep 17 00:00:00 2001
2 From: "Ondrej Zajicek (work)" <santiago@crfreenet.org>
3 Date: Thu, 3 May 2018 17:07:39 +0200
4 Subject: [PATCH 2/2] Better initialization of random generator
5
6 Use full time precision to initialize random generator. The old
7 code was prone to initialize it to the same values in specific
8 circumstances (boot without RTC, multiple VMs starting at once).
9 ---
10 sysdep/unix/io.c | 4 +++-
11 1 file changed, 3 insertions(+), 1 deletion(-)
12
13 diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
14 index 012deaf0..11a0d6f1 100644
15 --- a/sysdep/unix/io.c
16 +++ b/sysdep/unix/io.c
17 @@ -2144,7 +2144,9 @@ io_init(void)
18 // XXX init_times();
19 // XXX update_times();
20 boot_time = current_time();
21 - srandom((uint) (current_real_time() TO_S));
22 +
23 + u64 now = (u64) current_real_time();
24 + srandom((uint) (now ^ (now >> 32)));
25 }
26
27 static int short_loops = 0;
28 --
29 2.17.0
30