X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fsetup.c;h=12d224175fce53a40a48e3a407273db646287f7b;hb=daf4b02e92a15276eae294d05ca233c3fc145b46;hp=79e00e13ff71220b7e0494984e1d2a25dad30a56;hpb=82ae109eba3901127fcd5267872b0afd64af4a7c;p=adns.git diff --git a/src/setup.c b/src/setup.c index 79e00e1..12d2241 100644 --- a/src/setup.c +++ b/src/setup.c @@ -5,14 +5,15 @@ */ /* * This file is part of adns, which is - * Copyright (C) 1997-2000,2003,2006 Ian Jackson + * Copyright (C) 1997-2000,2003,2006,2014 Ian Jackson + * Copyright (C) 2014 Mark Wooding * Copyright (C) 1999-2000,2003,2006 Tony Finch * Copyright (C) 1991 Massachusetts Institute of Technology * (See the file INSTALL for full details.) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) + * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, @@ -21,8 +22,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program; if not, write to the Free Software Foundation. */ #include @@ -41,7 +41,7 @@ static void readconfig(adns_state ads, const char *filename, int warnmissing); -static void addserver(adns_state ads, const struct sockaddr *sa, int n) { +static void addserver(adns_state ads, const struct sockaddr *sa, int salen) { int i; adns_rr_addr *ss; char buf[ADNS_ADDR2TEXT_BUFLEN]; @@ -61,9 +61,9 @@ static void addserver(adns_state ads, const struct sockaddr *sa, int n) { } ss= ads->servers+ads->nservers; - assert(n <= sizeof(ss->addr)); - ss->len = n; - memcpy(&ss->addr, sa, n); + assert(salen <= sizeof(ss->addr)); + ss->len = salen; + memcpy(&ss->addr, sa, salen); ads->nservers++; } @@ -580,7 +580,7 @@ static int init_begin(adns_state *ads_r, adns_initflags flags, LIST_INIT(ads->intdone); ads->forallnext= 0; ads->nextid= 0x311f; - ads->nudp= 0; + ads->nudpsockets= 0; ads->tcpsocket= -1; adns__vbuf_init(&ads->tcpsend); adns__vbuf_init(&ads->tcprecv); @@ -604,7 +604,7 @@ static int init_finish(adns_state ads) { struct sockaddr_in sin; struct protoent *proto; struct udpsocket *udp; - int i, j; + int i; int r; if (!ads->nservers) { @@ -618,16 +618,16 @@ static int init_finish(adns_state ads) { } proto= getprotobyname("udp"); if (!proto) { r= ENOPROTOOPT; goto x_free; } - ads->nudp= 0; + ads->nudpsockets= 0; for (i=0; inservers; i++) { if (adns__udpsocket_by_af(ads, ads->servers[i].addr.sa.sa_family)) continue; - assert(ads->nudp < MAXUDP); - udp= &ads->udpsocket[ads->nudp]; + assert(ads->nudpsockets < MAXUDP); + udp= &ads->udpsockets[ads->nudpsockets]; udp->af= ads->servers[i].addr.sa.sa_family; udp->fd= socket(udp->af,SOCK_DGRAM,proto->p_proto); if (udp->fd < 0) { r= errno; goto x_free; } - ads->nudp++; + ads->nudpsockets++; r= adns__setnonblock(ads,udp->fd); if (r) { r= errno; goto x_closeudp; } } @@ -635,7 +635,7 @@ static int init_finish(adns_state ads) { return 0; x_closeudp: - for (j=0; jnudp; j++) close(ads->udpsocket[j].fd); + for (i=0; inudpsockets; i++) close(ads->udpsockets[i].fd); x_free: free(ads); return r; @@ -752,7 +752,7 @@ void adns_finish(adns_state ads) { else if (ads->intdone.head) adns__cancel(ads->output.head); else break; } - for (i=0; inudp; i++) close(ads->udpsocket[i].fd); + for (i=0; inudpsockets; i++) close(ads->udpsockets[i].fd); if (ads->tcpsocket >= 0) close(ads->tcpsocket); adns__vbuf_free(&ads->tcpsend); adns__vbuf_free(&ads->tcprecv);