forked from pool/c-ares
4c1bcc5dd1
Needed to fix envoy-proxy - Add upstream patches with the ares_getaddrinfo function: * 0001-Add-initial-implementation-for-ares_getaddrinfo-112.patch * 0002-Remaining-queries-counter-fix-additional-unit-tests-.patch * 0003-Bugfix-for-ares_getaddrinfo-and-additional-unit-test.patch * 0004-Add-ares__sortaddrinfo-to-support-getaddrinfo-sorted.patch * 0005-getaddrinfo-avoid-infinite-loop-in-case-of-NXDOMAIN-.patch * 0006-getaddrinfo-callback-must-be-called-on-bad-domain-24.patch * 0007-getaddrinfo-enhancements-257.patch * 0008-Add-missing-limits.h-include-from-ares_getaddrinfo.c.patch * 0009-Increase-portability-of-ares-test-mock-ai.cc-235.patch - Add a patch which disables test failing on OBS (but passing in local environment): * 0010-Disable-failing-test.patch OBS-URL: https://build.opensuse.org/request/show/742197 OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/c-ares?expand=0&rev=9
56 lines
1.8 KiB
Diff
56 lines
1.8 KiB
Diff
From 1dc228c872974d7eafc34b53816e973e00224351 Mon Sep 17 00:00:00 2001
|
|
From: kedixa <1204837541@qq.com>
|
|
Date: Tue, 9 Apr 2019 07:37:43 +0800
|
|
Subject: [PATCH 05/10] getaddrinfo: avoid infinite loop in case of
|
|
NXDOMAIN(#240) (#242)
|
|
|
|
There are two possible causes for infinite loops fo NXDOMAIN, based on how many dots are in the domain name (one for < ARES_OPT_NDOTS and one for >= ARES_OPT_NDOTS), where it will repeat the same query over and over as the hquery->next_domain doesn't increment.
|
|
|
|
Fix By: @kedixa
|
|
---
|
|
ares_getaddrinfo.c | 21 +++++++++++++++------
|
|
1 file changed, 15 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/ares_getaddrinfo.c b/ares_getaddrinfo.c
|
|
index ebaeda8..16c8b38 100644
|
|
--- a/ares_getaddrinfo.c
|
|
+++ b/ares_getaddrinfo.c
|
|
@@ -122,7 +122,7 @@ void ares_getaddrinfo(ares_channel channel,
|
|
hquery->callback = callback;
|
|
hquery->arg = arg;
|
|
hquery->timeouts = 0;
|
|
- hquery->next_domain = 0;
|
|
+ hquery->next_domain = -1; /* see next_dns_lookup for more info */
|
|
hquery->remaining = 0;
|
|
|
|
/* Host file lookup */
|
|
@@ -279,11 +279,20 @@ static void next_dns_lookup(struct host_query *hquery) {
|
|
char *s = NULL;
|
|
int is_s_allocated = 0;
|
|
int status;
|
|
-
|
|
- if (( as_is_first(hquery) && hquery->next_domain == 0) ||
|
|
- (!as_is_first(hquery) && hquery->next_domain ==
|
|
- hquery->channel->ndomains)) {
|
|
- s = hquery->name;
|
|
+ /* if next_domain == -1 and as_is_first is true, try hquery->name */
|
|
+ if(hquery->next_domain == -1) {
|
|
+ if(as_is_first(hquery)) {
|
|
+ s = hquery->name;
|
|
+ }
|
|
+ hquery->next_domain = 0;
|
|
+ }
|
|
+ /* if as_is_first is false, try hquery->name at last */
|
|
+ if(!s && hquery->next_domain == hquery->channel->ndomains) {
|
|
+ if(!as_is_first(hquery)) {
|
|
+ s = hquery->name;
|
|
+ }
|
|
+ /* avoid infinite loop */
|
|
+ hquery->next_domain++;
|
|
}
|
|
|
|
if (!s && hquery->next_domain < hquery->channel->ndomains) {
|
|
--
|
|
2.16.4
|
|
|