*/
#include <string.h>
+#include <assert.h>
+#include <limits.h>
#include "secnet.h"
#include "util.h"
#include "ipaddr.h"
/* All the networks serviced by the various tunnels should now
* have been registered. We build a routing table by sorting the
* clients by priority. */
- st->routes=safe_malloc(st->n_clients*sizeof(*st->routes),
- "netlink_phase_hook");
+ st->routes=safe_malloc_ary(sizeof(*st->routes),st->n_clients,
+ "netlink_phase_hook");
/* Fill the table */
i=0;
- for (c=st->clients; c; c=c->next)
+ for (c=st->clients; c; c=c->next) {
+ assert(i<INT_MAX);
st->routes[i++]=c;
+ }
/* Sort the table in descending order of priority */
qsort(st->routes,st->n_clients,sizeof(*st->routes),
netlink_compare_client_priority);
c->kup=False;
c->next=st->clients;
st->clients=c;
+ assert(st->n_clients < INT_MAX);
st->n_clients++;
return &c->cl;
return new_closure(&st->nl.cl);
}
-init_module netlink_module;
void netlink_module(dict_t *dict)
{
add_closure(dict,"null-netlink",null_apply);