1
0
mirror of https://git.openwrt.org/feed/routing.git synced 2024-06-26 09:37:31 +02:00
openwrt-routing/bird2/patches/0005-Better-initialization-of-random-generator.patch
Toke Høiland-Jørgensen 688901a664 bird2: Add package
This adds a separate package for the 2.0 branch of Bird, allowing it to
co-exist with the bird1 package. The two packages conflict with each other,
so they can't be installed at the same time; but in the build system they
coexist just fine.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
2018-05-16 13:18:28 +02:00

31 lines
918 B
Diff

From eaf63d314d50cba5b2cfa8f18de64a91d3131b94 Mon Sep 17 00:00:00 2001
From: "Ondrej Zajicek (work)" <santiago@crfreenet.org>
Date: Thu, 3 May 2018 17:07:39 +0200
Subject: [PATCH 2/2] 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).
---
sysdep/unix/io.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 012deaf0..11a0d6f1 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;
--
2.17.0