rb_dlink_list auth_providers;
static rb_dlink_list free_pids;
-static uint32_t pid;
+static uint32_t allocated_pids;
static struct ev_entry *timeout_ev;
/* Initalise all providers */
}
else
{
- if(pid == UINT32_MAX)
+ if(allocated_pids == MAX_PROVIDERS || allocated_pids == UINT32_MAX)
{
- /* If this happens, well, I don't know what to say. Probably a bug.
- * In any case, UINT32_MAX is a special sentinel. */
warn_opers(L_WARN, "Cannot load additional provider, max reached!");
return;
}
- provider->id = pid++;
+ provider->id = allocated_pids++;
}
if(provider->opt_handlers != NULL)
lrb_assert(is_provider_running(auth, id));
lrb_assert(id != UINT32_MAX);
- lrb_assert(id <= pid);
+ lrb_assert(id < allocated_pids);
set_provider_done(auth, id);
rb_strlcpy(auth->hostname, "*", sizeof(auth->hostname));
rb_strlcpy(auth->username, "*", sizeof(auth->username));
- /* FIXME this is unsafe, the list being allocated needs to
- * support the maximum PID allocated, not just the current
- * length of auth_providers */
- auth->data = rb_malloc(rb_dlink_list_length(&auth_providers) *
- sizeof(struct auth_client_data));
+ auth->data = rb_malloc(allocated_pids * sizeof(struct auth_client_data));
auth->providers_starting = true;
RB_DLINK_FOREACH(ptr, auth_providers.head)