X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=adns.git;a=blobdiff_plain;f=src%2Freply.c;h=ab7c8ff4aadbc37c6cdb589baf43b49aa384cc88;hp=6198d07dccb8a1c01844495fdf94d2ab9e67f332;hb=c3ca23bb1821f820dfa889dc006599b5df8af32f;hpb=ea1e31e326a99219a0a6edf28a75845b79b74893 diff --git a/src/reply.c b/src/reply.c index 6198d07..ab7c8ff 100644 --- a/src/reply.c +++ b/src/reply.c @@ -3,7 +3,7 @@ * - main handling and parsing routine for received datagrams */ /* - * This file is part of adns, which is Copyright (C) 1997, 1998 Ian Jackson + * This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson * * 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 @@ -33,6 +33,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, int rrtype, rrclass, rdlength, rdstart; int anstart, nsstart, arstart; int ownermatched, l, nrrs; + unsigned long ttl, soattl; const typeinfo *typei; adns_query qu, nqu; dns_rcode rcode; @@ -138,7 +139,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, for (rri= 0; rritypei->type & adns__rrt_typemask) != adns_r_cname) { - if (!qu->cname_dgram) { /* Ignore second and subsequent CNAMEs */ + if (qu->flags & adns_qf_cname_forbid) { + adns__query_fail(qu,adns_s_prohibitedcname); + return; + } else if (!qu->cname_dgram) { /* Ignore second and subsequent CNAMEs */ qu->cname_begin= rdstart; qu->cname_dglen= dglen; st= adns__parse_domain(ads,serv,qu, &qu->vb, @@ -174,6 +178,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, memcpy(qu->answer->cname,qu->vb.buf,l); cname_here= 1; + adns__update_expires(qu,ttl,now); /* If we find the answer section truncated after this point we restart * the query at the CNAME; if beforehand then we obviously have to use * TCP. If there is no truncation we can use the whole answer if @@ -200,18 +205,13 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, if (!wantedrrs) { /* Oops, NODATA or NXDOMAIN or perhaps a referral (which would be a problem) */ - - if (rcode == rcode_nxdomain) { - adns__query_fail(qu,adns_s_nxdomain); - return; - } /* RFC2308: NODATA has _either_ a SOA _or_ _no_ NS records in authority section */ - foundsoa= 0; foundns= 0; + foundsoa= 0; soattl= 0; foundns= 0; for (rri= 0; rriflags & adns_qf_search) { + adns__search_next(ads,qu,now); + } else { + adns__query_fail(qu,adns_s_nxdomain); + } + return; + } if (foundsoa || !foundns) { /* Aha ! A NODATA response, good. */ + adns__update_expires(qu,soattl,now); adns__query_fail(qu,adns_s_nodata); return; } @@ -272,13 +285,14 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, for (rri=0, nrrs=0; rritypei->type & adns__rrt_typemask) || !ownermatched) continue; + adns__update_expires(qu,ttl,now); st= typei->parse(&pai, rdstart,rdstart+rdlength, rrsdata+nrrs*typei->rrsz); if (st) { adns__query_fail(qu,st); return; } if (rdstart==-1) goto x_truncated;