X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=netlink.c;h=70eb9283b080104e37131d65170cdd7581988988;hb=bb9d056157e37451ec14800d5914733a625f1901;hp=cc954fd748bd7d8677cd2487987aac8f84f434c4;hpb=ea7ec970f650793fa9cc5d308a1fceb3e3d74336;p=secnet.git diff --git a/netlink.c b/netlink.c index cc954fd..70eb928 100644 --- a/netlink.c +++ b/netlink.c @@ -98,6 +98,8 @@ their use. */ #include +#include +#include #include "secnet.h" #include "util.h" #include "ipaddr.h" @@ -766,12 +768,14 @@ static void netlink_phase_hook(void *sst, uint32_t new_phase) /* 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(iroutes[i++]=c; + } /* Sort the table in descending order of priority */ qsort(st->routes,st->n_clients,sizeof(*st->routes), netlink_compare_client_priority); @@ -911,6 +915,7 @@ static closure_t *netlink_inst_create(struct netlink *st, c->kup=False; c->next=st->clients; st->clients=c; + assert(st->n_clients < INT_MAX); st->n_clients++; return &c->cl; @@ -1067,7 +1072,6 @@ static list_t *null_apply(closure_t *self, struct cloc loc, dict_t *context, return new_closure(&st->nl.cl); } -init_module netlink_module; void netlink_module(dict_t *dict) { add_closure(dict,"null-netlink",null_apply);