Revert "BUG/MINOR: dns: SRV records ignores duplicated AR records"

This reverts commit 949a7f64591458eb06c998acf409093ea991dc3a.

The first part of the patch introduces a bug. When a dns answer item is
allocated, its <ar_item> is only initialized at the end of the parsing, when
the item is added in the answer list. Thus, we must not try to release it
during the parsing.

The second part is also probably buggy. It fixes the issue #971 but reverts
a fix for the issue #841 (see commit fb0884c8297 "BUG/MEDIUM: dns: Don't
store additional records in a linked-list"). So it must be at least
revalidated.

This revert fixes a segfault reported in a comment of the issue #971. It
must be backported as far as 2.2.
This commit is contained in:
Christopher Faulet 2021-01-12 10:27:26 +01:00
parent 76603f2552
commit a1eea3bbb1

View File

@ -1027,10 +1027,6 @@ static int dns_validate_dns_response(unsigned char *resp, unsigned char *bufend,
dns_answer_record->data_len = len; dns_answer_record->data_len = len;
memcpy(dns_answer_record->target, tmpname, len); memcpy(dns_answer_record->target, tmpname, len);
dns_answer_record->target[len] = 0; dns_answer_record->target[len] = 0;
if (dns_answer_record->ar_item != NULL) {
pool_free(dns_answer_item_pool, dns_answer_record->ar_item);
dns_answer_record->ar_item = NULL;
}
break; break;
case DNS_RTYPE_AAAA: case DNS_RTYPE_AAAA:
@ -1280,7 +1276,6 @@ static int dns_validate_dns_response(unsigned char *resp, unsigned char *bufend,
// looking for the SRV record in the response list linked to this additional record // looking for the SRV record in the response list linked to this additional record
list_for_each_entry(tmp_record, &dns_p->answer_list, list) { list_for_each_entry(tmp_record, &dns_p->answer_list, list) {
if (tmp_record->type == DNS_RTYPE_SRV && if (tmp_record->type == DNS_RTYPE_SRV &&
tmp_record->ar_item == NULL &&
!dns_hostname_cmp(tmp_record->target, dns_answer_record->name, tmp_record->data_len)) { !dns_hostname_cmp(tmp_record->target, dns_answer_record->name, tmp_record->data_len)) {
/* Always use the received additional record to refresh info */ /* Always use the received additional record to refresh info */
if (tmp_record->ar_item) if (tmp_record->ar_item)