Fix order of calls to resize-packet() and add_pseudoheader().

Avoids malformed replies with EDE in certain circumstances.
This commit is contained in:
Simon Kelley
2021-07-04 22:38:26 +01:00
parent 5bcca1219a
commit 857b445522

View File

@@ -734,12 +734,6 @@ static size_t process_reply(struct dns_header *header, time_t now, struct server
} }
#endif #endif
if (pheader && ede != -1)
{
u16 swap = htons((u16)ede);
n = add_pseudoheader(header, n, limit, daemon->edns_pktsz, EDNS0_OPTION_EDE, (unsigned char *)&swap, 2, do_bit, 1);
}
/* do this after extract_addresses. Ensure NODATA reply and remove /* do this after extract_addresses. Ensure NODATA reply and remove
nameserver info. */ nameserver info. */
if (munged) if (munged)
@@ -753,7 +747,15 @@ static size_t process_reply(struct dns_header *header, time_t now, struct server
/* the bogus-nxdomain stuff, doctor and NXDOMAIN->NODATA munging can all elide /* the bogus-nxdomain stuff, doctor and NXDOMAIN->NODATA munging can all elide
sections of the packet. Find the new length here and put back pseudoheader sections of the packet. Find the new length here and put back pseudoheader
if it was removed. */ if it was removed. */
return resize_packet(header, n, pheader, plen); n = resize_packet(header, n, pheader, plen);
if (pheader && ede != -1)
{
u16 swap = htons((u16)ede);
n = add_pseudoheader(header, n, limit, daemon->edns_pktsz, EDNS0_OPTION_EDE, (unsigned char *)&swap, 2, do_bit, 1);
}
return n;
} }
#ifdef HAVE_DNSSEC #ifdef HAVE_DNSSEC