X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Freply.c;h=caf5c05a95f66090022837488bedb701fa2ba9e4;hb=814cee186999a6e9a76ab970f891347c1e42b132;hp=83c343110ad54f76c34ee97330dc8222ca6ef338;hpb=26e1c3d691b52d21a8bb52d9bf3f8e2b42ae6cfa;p=adns.git diff --git a/src/reply.c b/src/reply.c index 83c3431..caf5c05 100644 --- a/src/reply.c +++ b/src/reply.c @@ -4,7 +4,8 @@ */ /* * This file is part of adns, which is - * Copyright (C) 1997-2000,2003,2006,2014 Ian Jackson + * Copyright (C) 1997-2000,2003,2006,2014-2016,2020 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.) @@ -34,7 +35,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, int flg_ra, flg_rd, flg_tc, flg_qr, opcode; int rrtype, rrclass, rdlength, rdstart; int anstart, nsstart; - int ownermatched, l, nrrs; + int ownermatched, l, nrrs, restartfrom; unsigned long ttl, soattl; const typeinfo *typei; adns_query qu, nqu; @@ -161,6 +162,7 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, * If it has any CNAMEs we stuff them in the answer. */ wantedrrs= 0; + restartfrom= -1; cbyte= anstart; for (rri= 0; rrianswer->type & adns_rrt_typemask)) { + if (restartfrom==-1) restartfrom= rri; wantedrrs++; } else { adns__debug(ads,serv,qu,"ignoring answer RR" @@ -330,13 +333,15 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, pai.arcount= arcount; pai.now= now; + assert(restartfrom>=0); for (rri=0, nrrs=0; rrianswer->type & adns_rrt_typemask) || + rrclass != DNS_CLASS_IN || !ownermatched) continue; adns__update_expires(qu,ttl,now); @@ -365,6 +370,11 @@ void adns__procdgram(adns_state ads, const byte *dgram, int dglen, adns__query_fail(qu,adns_s_invalidresponse); return; } + if (qu->flags & adns_qf_usevc) { + adns__diag(ads,serv,qu,"server sent datagram with TC over TCP"); + adns__query_fail(qu,adns_s_invalidresponse); + return; + } qu->flags |= adns_qf_usevc; x_restartquery: