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 <j@w1.fi>
This commit is contained in:
Jouni Malinen 2020-03-08 16:43:09 +02:00
parent 17ba51b14d
commit a17cbcd698
1 changed files with 2 additions and 2 deletions

View 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;
}