mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-10-27 14:41:28 +01:00
BUG/MEDIUM: resolvers: break an infinite loop in resolv_get_ip_from_response()
The fix in 3023e98199 ("BUG/MINOR: resolvers: Restore round-robin
selection on records in DNS answers") still contained an issue not
addressed f6dfbbe870 ("BUG/MEDIUM: resolvers: Test for empty tree
when getting a record from DNS answer"). Indeed, if the next element
is the same as the first one, then we can end up with an endless loop
because the test at the end compares the next pointer (possibly null)
with the end one (first).
Let's move the null->first transition at the end. This must be
backported where the patches above were backported (3.2 for now).
This commit is contained in:
parent
ad75431b9c
commit
ced9784df4
@ -1651,15 +1651,12 @@ int resolv_get_ip_from_response(struct resolv_response *r_res,
|
|||||||
* The result with the biggest score is returned.
|
* The result with the biggest score is returned.
|
||||||
*/
|
*/
|
||||||
eb32 = (!r_res->next) ? eb32_first(&r_res->answer_tree) : r_res->next;
|
eb32 = (!r_res->next) ? eb32_first(&r_res->answer_tree) : r_res->next;
|
||||||
end = r_res->next;
|
end = eb32;
|
||||||
r_res->next = eb32_next(eb32); /* get node for the next lookup */
|
r_res->next = eb32_next(eb32); /* get node for the next lookup */
|
||||||
do {
|
do {
|
||||||
void *ip;
|
void *ip;
|
||||||
unsigned char ip_type;
|
unsigned char ip_type;
|
||||||
|
|
||||||
if (eb32 == NULL)
|
|
||||||
eb32 = eb32_first(&r_res->answer_tree);
|
|
||||||
|
|
||||||
record = eb32_entry(eb32, typeof(*record), link);
|
record = eb32_entry(eb32, typeof(*record), link);
|
||||||
if (record->type == DNS_RTYPE_A && (resolv_active_families() & RSLV_ACCEPT_IPV4)) {
|
if (record->type == DNS_RTYPE_A && (resolv_active_families() & RSLV_ACCEPT_IPV4)) {
|
||||||
ip_type = AF_INET;
|
ip_type = AF_INET;
|
||||||
@ -1758,6 +1755,8 @@ int resolv_get_ip_from_response(struct resolv_response *r_res,
|
|||||||
}
|
}
|
||||||
next:
|
next:
|
||||||
eb32 = eb32_next(eb32);
|
eb32 = eb32_next(eb32);
|
||||||
|
if (eb32 == NULL)
|
||||||
|
eb32 = eb32_first(&r_res->answer_tree);
|
||||||
} while (eb32 != end); /* list for each record entries */
|
} while (eb32 != end); /* list for each record entries */
|
||||||
|
|
||||||
/* No IP found in the response */
|
/* No IP found in the response */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user