From 167205d455cef9832c5dfc887afb22a7f2f2d8a8 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 28 Feb 2020 22:54:36 +0200 Subject: [PATCH] os_unix: Seed random() for os_random() While the users of os_random() do not really need strong pseudo random numebrs, there is no significant harm in seeding random() with data from os_get_random(), i.e., /dev/urandom, to get different sequence of not so strong pseudo random values from os_random() for each time the process is started. Signed-off-by: Jouni Malinen --- src/utils/os_unix.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c index dd504f3ab..fc1110b3c 100644 --- a/src/utils/os_unix.c +++ b/src/utils/os_unix.c @@ -337,6 +337,8 @@ char * os_rel2abs_path(const char *rel_path) int os_program_init(void) { + unsigned int seed; + #ifdef ANDROID /* * We ignore errors here since errors are normal if we @@ -365,6 +367,9 @@ int os_program_init(void) capset(&header, &cap); #endif /* ANDROID */ + os_get_random((unsigned char *) &seed, sizeof(seed)); + srandom(seed); + return 0; }