Make getrandom() failure fatal

This commit is contained in:
Sami Farin 2021-01-22 19:24:52 +01:00 committed by Wim Taymans
parent 8b4fbac187
commit 906a1f5448

View file

@ -405,15 +405,17 @@ 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();
while (getrandom(&this->info.cookie, sizeof(this->info.cookie), 0) != do {
sizeof(this->info.cookie)) { res = getrandom(&this->info.cookie,
if (errno == EINTR) sizeof(this->info.cookie), 0);
continue; } while ((res == -1) && (errno == EINTR));
pw_log_warn(NAME" %p: cookie getrandom failed: %m", this); if (res == -1) {
this->info.cookie = rand(); res = -errno;
break; goto error_exit;
} else if (res != sizeof(this->info.cookie)) {
res = -ENODATA;
goto error_exit;
} }
this->info.name = name; this->info.name = name;
spa_hook_list_init(&this->listener_list); spa_hook_list_init(&this->listener_list);