From a17cbcd698d53cbf3dece9c7b71f0f77afd19ee9 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 8 Mar 2020 16:43:09 +0200 Subject: [PATCH] os_unix: Call srandom() only if os_get_random() succeeds Don't use uninitialized stack memory if /dev/urandom is not available. Signed-off-by: Jouni Malinen --- src/utils/os_unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c index fc1110b3c..6f0c17756 100644 --- a/src/utils/os_unix.c +++ b/src/utils/os_unix.c @@ -367,8 +367,8 @@ int os_program_init(void) capset(&header, &cap); #endif /* ANDROID */ - os_get_random((unsigned char *) &seed, sizeof(seed)); - srandom(seed); + if (os_get_random((unsigned char *) &seed, sizeof(seed)) == 0) + srandom(seed); return 0; } -- 2.47.2