]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
os_unix: Call srandom() only if os_get_random() succeeds
authorJouni Malinen <j@w1.fi>
Sun, 8 Mar 2020 14:43:09 +0000 (16:43 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 8 Mar 2020 14:43:09 +0000 (16:43 +0200)
Don't use uninitialized stack memory if /dev/urandom is not available.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/utils/os_unix.c

index fc1110b3cc121e79f87dcf91cd3a990e1b924ef0..6f0c1775666ff47c5ffffece08adb44326b11b4e 100644 (file)
@@ -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;
 }