New CNAME code shouldn't spin on CNAME loops.

This commit is contained in:
Simon Kelley
2019-11-30 21:07:15 +00:00
parent 4a1c21d62c
commit 1aef66bb34

View File

@@ -1352,6 +1352,8 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
for (q = ntohs(header->qdcount); q != 0; q--)
{
int count = 255; /* catch loops */
/* save pointer to name for copying into answers */
nameoffset = p - (unsigned char *)header;
@@ -1364,7 +1366,7 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
ans = 0; /* have we answered this question */
while ((crecp = cache_find_by_name(NULL, name, now, F_CNAME)))
while (--count != 0 && (crecp = cache_find_by_name(NULL, name, now, F_CNAME)))
{
char *cname_target = cache_get_cname_target(crecp);