impl-core: use getrandom for cookie

Fixes #583
This commit is contained in:
Wim Taymans 2021-01-22 15:47:12 +01:00
parent 0dad70eb48
commit 9a6888486f

View file

@ -24,6 +24,7 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/random.h>
#include <spa/debug/types.h> #include <spa/debug/types.h>
@ -404,8 +405,7 @@ struct pw_impl_core *pw_context_create_core(struct pw_context *context,
this->info.user_name = pw_get_user_name(); this->info.user_name = pw_get_user_name();
this->info.host_name = pw_get_host_name(); this->info.host_name = pw_get_host_name();
this->info.version = pw_get_library_version(); this->info.version = pw_get_library_version();
srandom(time(NULL)); getrandom(&this->info.cookie, sizeof(this->info.cookie), 0);
this->info.cookie = random();
this->info.name = name; this->info.name = name;
spa_hook_list_init(&this->listener_list); spa_hook_list_init(&this->listener_list);