From cde0b7632d699d6b4a16035708c3104142121cf4 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Thu, 23 Jul 2020 22:12:07 +0200 Subject: [PATCH] Set additional record count properly in NS reply For when there is no IPv4 address to return. --- src/dns.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/dns.c b/src/dns.c index 9741606..7d85e19 100644 --- a/src/dns.c +++ b/src/dns.c @@ -260,7 +260,6 @@ int dns_encode_ns_response(char *buf, size_t buflen, struct query *q, header->qdcount = htons(1); header->ancount = htons(1); - header->arcount = htons(1); /* pointer to start of name */ name = 0xc000 | ((p - buf) & 0x3fff); @@ -302,6 +301,10 @@ int dns_encode_ns_response(char *buf, size_t buflen, struct query *q, /* Do we have an IPv4 address to send? */ if (q->destination.ss_family == AF_INET) { struct sockaddr_in *dest = (struct sockaddr_in *) &q->destination; + + /* One additional record coming */ + header->arcount = htons(1); + /* Additional data (A-record of NS server) */ CHECKLEN(12); putshort(&p, nsname); /* Name Server */