X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=secnet.git;a=blobdiff_plain;f=netlink.c;h=75763cf520719fc1bfc2934da725344121c35aa0;hp=07c1468488ad42235ad37457fbec903059159dcb;hb=94ca562bb14422940ff1986ce8dfca87c222cb59;hpb=4f28e77ed21e75fcfb30e2f8d1d2b9b1657f44c6 diff --git a/netlink.c b/netlink.c index 07c1468..75763cf 100644 --- a/netlink.c +++ b/netlink.c @@ -386,7 +386,7 @@ static uint16_t netlink_icmp_reply_len(struct buffer_if *buf) /* We include the first 8 bytes of the packet data, provided they exist */ hlen+=8; plen=ntohs(iph->tot_len); - return (hlen>plen?plen:hlen); + return MIN(hlen,plen); } /* client indicates where the packet we're constructing a response to @@ -976,7 +976,6 @@ static void netlink_output_subnets(struct netlink *st, uint32_t loglevel, for (i=0; ientries; i++) { net=subnet_to_string(snets->list[i]); Message(loglevel,"%s ",net); - free(net); } } @@ -1014,7 +1013,6 @@ static void netlink_dump_routes(struct netlink *st, bool_t requested) for (i=0; isubnets->entries; i++) { net=subnet_to_string(st->subnets->list[i]); Message(c,"%s ",net); - free(net); } if (i>0) Message(c,"-> host (use %d)\n",st->outcount); @@ -1041,8 +1039,7 @@ 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_ary(sizeof(*st->routes),st->n_clients, - "netlink_phase_hook"); + NEW_ARY(st->routes,st->n_clients); /* Fill the table */ i=0; for (c=st->clients; c; c=c->next) { @@ -1140,7 +1137,7 @@ static closure_t *netlink_inst_create(struct netlink *st, return NULL; } - c=safe_malloc(sizeof(*c),"netlink_inst_create"); + NEW(c); c->cl.description=name; c->cl.type=CL_NETLINK; c->cl.apply=NULL; @@ -1309,7 +1306,7 @@ static list_t *null_apply(closure_t *self, struct cloc loc, dict_t *context, item_t *item; dict_t *dict; - st=safe_malloc(sizeof(*st),"null_apply"); + NEW(st); item=list_elem(args,0); if (!item || item->type!=t_dict)