CLEANUP: always initialize the answer_list
authorWilly Tarreau <w@1wt.eu>
Tue, 19 Oct 2021 09:29:21 +0000 (11:29 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Nov 2021 11:00:12 +0000 (12:00 +0100)
Similar to the previous patch, the answer's list was only initialized the
first time it was added to a list, leading to bogus outdated pointer to
appear when debugging code is added around it to watch it. Let's make
sure it's always initialized upon allocation.

(cherry picked from commit 48664c048d17486b80e58459d2d4fa41a36e579e)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit a2373e82f574fdba5fb52ff0ef917b16dd44484a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/dns.c

index 1c62106..dee243d 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -1067,6 +1067,7 @@ static int dns_validate_dns_response(unsigned char *resp, unsigned char *bufend,
                dns_answer_record->ar_item = NULL;
                dns_answer_record->last_seen = TICK_ETERNITY;
                LIST_INIT(&dns_answer_record->attached_servers);
+               LIST_INIT(&dns_answer_record->list);
 
                offset = 0;
                len = dns_read_name(resp, bufend, reader, tmpname, DNS_MAX_NAME_SIZE, &offset, 0);