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

View File

@ -367,8 +367,8 @@ int os_program_init(void)
capset(&header, &cap); capset(&header, &cap);
#endif /* ANDROID */ #endif /* ANDROID */
os_get_random((unsigned char *) &seed, sizeof(seed)); if (os_get_random((unsigned char *) &seed, sizeof(seed)) == 0)
srandom(seed); srandom(seed);
return 0; return 0;
} }