summaryrefslogtreecommitdiffstats
path: root/rfc1035/rfc1035resolve.c
diff options
context:
space:
mode:
authorSam Varshavchik2020-04-09 22:11:25 -0400
committerSam Varshavchik2020-04-09 22:21:25 -0400
commitcc65aa46efd006608ebb5d24bf773e3da12d6e8e (patch)
treea3b64688cd5a4697a039576259cc3c80c04a59f2 /rfc1035/rfc1035resolve.c
parent085e7c04474eeb0666a753f7cf5b7438616fc43b (diff)
downloadcourier-libs-cc65aa46efd006608ebb5d24bf773e3da12d6e8e.tar.bz2
Fix AXFR processing.
Diffstat (limited to 'rfc1035/rfc1035resolve.c')
-rw-r--r--rfc1035/rfc1035resolve.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/rfc1035/rfc1035resolve.c b/rfc1035/rfc1035resolve.c
index f438719..6ba95fc 100644
--- a/rfc1035/rfc1035resolve.c
+++ b/rfc1035/rfc1035resolve.c
@@ -290,6 +290,14 @@ static struct rfc1035_reply
int nbytes;
char *reply;
struct rfc1035_reply *rfcreply;
+ unsigned i;
+
+ /*
+ ** First record in axfr will be an SOA. Start searching for the
+ ** trailing SOA starting with record 1. In case of multiple responses
+ ** we'll start looking with element 0, again.
+ */
+ unsigned check_soa=1;
int tcpfd;
struct rfc1035_reply *firstreply=0, *lastreply=0;
@@ -320,6 +328,18 @@ static struct rfc1035_reply
firstreply=lastreply=rfcreply;
while (isaxfr && rfcreply->rcode == 0)
{
+ for (i=check_soa; i<rfcreply->ancount; ++i)
+ {
+ if (rfcreply->anptr[i].rrtype ==
+ RFC1035_TYPE_SOA)
+ break;
+ }
+
+ if (i < rfcreply->ancount)
+ break; /* Found trailing SOA */
+
+ check_soa=0;
+
if ((reply=rfc1035_recv_tcp(res,
tcpfd, &nbytes, current_timeout))==0)
break;
@@ -335,11 +355,6 @@ static struct rfc1035_reply
rfcreply->mallocedbuf=reply;
lastreply->next=rfcreply;
lastreply=rfcreply;
-
- if ( rfcreply->ancount &&
- rfcreply->anptr[0].rrtype ==
- RFC1035_TYPE_SOA)
- break;
}
sox_close(tcpfd);