From: Jouni Malinen Date: Sun, 8 Mar 2020 14:43:09 +0000 (+0200) Subject: os_unix: Call srandom() only if os_get_random() succeeds X-Git-Tag: hostap_2_10~1646 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a17cbcd698d53cbf3dece9c7b71f0f77afd19ee9;p=thirdparty%2Fhostap.git 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 --- 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; }