summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-contrib <[email protected]>2025-04-13 13:47:11 +0300
committerrobot-contrib <[email protected]>2025-04-13 14:00:42 +0300
commite5e1887810c1a3b3a6ea372adf18988cab90b35c (patch)
tree9ee0f2233ae340ec2926d31b73d0284795eaf6e7
parent425ef11b132e60faac2e4e387d565be01fa96975 (diff)
Update contrib/libs/c-ares to 1.34.5
Fixes-31498](https://securityvulnerability.io/vulnerability/CVE-2025-31498). commit_hash:6e6152695e1aed97b6ca7f6f304fbdcc15b71ed7
-rw-r--r--contrib/libs/c-ares/.yandex_meta/override.nix4
-rw-r--r--contrib/libs/c-ares/RELEASE-NOTES.md33
-rw-r--r--contrib/libs/c-ares/include/ares_dns_record.h2
-rw-r--r--contrib/libs/c-ares/include/ares_version.h4
-rw-r--r--contrib/libs/c-ares/src/lib/ares_addrinfo2hostent.c169
-rw-r--r--contrib/libs/c-ares/src/lib/ares_addrinfo_localhost.c54
-rw-r--r--contrib/libs/c-ares/src/lib/ares_close_sockets.c2
-rw-r--r--contrib/libs/c-ares/src/lib/ares_config-linux.h3
-rw-r--r--contrib/libs/c-ares/src/lib/ares_cookie.c8
-rw-r--r--contrib/libs/c-ares/src/lib/ares_free_hostent.c7
-rw-r--r--contrib/libs/c-ares/src/lib/ares_getaddrinfo.c10
-rw-r--r--contrib/libs/c-ares/src/lib/ares_gethostbyaddr.c2
-rw-r--r--contrib/libs/c-ares/src/lib/ares_gethostbyname.c12
-rw-r--r--contrib/libs/c-ares/src/lib/ares_hosts_file.c8
-rw-r--r--contrib/libs/c-ares/src/lib/ares_ipv6.h10
-rw-r--r--contrib/libs/c-ares/src/lib/ares_metrics.c2
-rw-r--r--contrib/libs/c-ares/src/lib/ares_private.h8
-rw-r--r--contrib/libs/c-ares/src/lib/ares_process.c107
-rw-r--r--contrib/libs/c-ares/src/lib/ares_sysconfig_win.c31
-rw-r--r--contrib/libs/c-ares/src/lib/config-win32.h8
-rw-r--r--contrib/libs/c-ares/src/lib/event/ares_event.h25
-rw-r--r--contrib/libs/c-ares/src/lib/event/ares_event_configchg.c19
-rw-r--r--contrib/libs/c-ares/src/lib/event/ares_event_epoll.c4
-rw-r--r--contrib/libs/c-ares/src/lib/event/ares_event_kqueue.c4
-rw-r--r--contrib/libs/c-ares/src/lib/event/ares_event_poll.c5
-rw-r--r--contrib/libs/c-ares/src/lib/event/ares_event_select.c9
-rw-r--r--contrib/libs/c-ares/src/lib/event/ares_event_thread.c16
-rw-r--r--contrib/libs/c-ares/src/lib/event/ares_event_wake_pipe.c16
-rw-r--r--contrib/libs/c-ares/src/lib/event/ares_event_win32.c8
-rw-r--r--contrib/libs/c-ares/src/lib/legacy/ares_parse_a_reply.c1
-rw-r--r--contrib/libs/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c1
-rw-r--r--contrib/libs/c-ares/src/lib/util/ares_iface_ips.c8
-rw-r--r--contrib/libs/c-ares/src/lib/util/ares_uri.h2
-rw-r--r--contrib/libs/c-ares/ya.make4
34 files changed, 404 insertions, 202 deletions
diff --git a/contrib/libs/c-ares/.yandex_meta/override.nix b/contrib/libs/c-ares/.yandex_meta/override.nix
index 64407f85a0f..c7309f5cd92 100644
--- a/contrib/libs/c-ares/.yandex_meta/override.nix
+++ b/contrib/libs/c-ares/.yandex_meta/override.nix
@@ -1,11 +1,11 @@
pkgs: attrs: with pkgs; with attrs; rec {
- version = "1.34.4";
+ version = "1.34.5";
src = fetchFromGitHub {
owner = "c-ares";
repo = "c-ares";
rev= "v${version}";
- hash = "sha256-6xJSo4ptXAKFwCUBRAji8DSqkxoIL6lpWvnDOM1NQNg=";
+ hash = "sha256-MeQ4eqt7QyRD7YVomXR+fwBzraiYe2s2Eozz0sE8Xgo=";
};
patches = [];
diff --git a/contrib/libs/c-ares/RELEASE-NOTES.md b/contrib/libs/c-ares/RELEASE-NOTES.md
index 19a204b3ea9..1a8d8d22333 100644
--- a/contrib/libs/c-ares/RELEASE-NOTES.md
+++ b/contrib/libs/c-ares/RELEASE-NOTES.md
@@ -1,25 +1,28 @@
-## c-ares version 1.34.4 - December 14 2024
+## c-ares version 1.34.5 - April 8 2025
-This is a bugfix release.
+This is a security release.
+
+Security:
+* CVE-2025-31498. A use-after-free bug has been uncovered in read_answers() that
+ was introduced in v1.32.3. Please see https://github.com/c-ares/c-ares/security/advisories/GHSA-6hxc-62jh-p29v
Changes:
-* QNX Port: Port to QNX 8, add primary config reading support, add CI build. [PR #934](https://github.com/c-ares/c-ares/pull/934), [PR #937](https://github.com/c-ares/c-ares/pull/937), [PR #938](https://github.com/c-ares/c-ares/pull/938)
+* Restore Windows XP support. [PR #958](https://github.com/c-ares/c-ares/pull/958)
Bugfixes:
-* Empty TXT records were not being preserved. [PR #922](https://github.com/c-ares/c-ares/pull/922)
-* docs: update deprecation notices for `ares_create_query()` and `ares_mkquery()`. [PR #910](https://github.com/c-ares/c-ares/pull/910)
-* license: some files weren't properly updated. [PR #920](https://github.com/c-ares/c-ares/pull/920)
-* Fix bind local device regression from 1.34.0. [PR #929](https://github.com/c-ares/c-ares/pull/929), [PR #931](https://github.com/c-ares/c-ares/pull/931), [PR #935](https://github.com/c-ares/c-ares/pull/935)
-* CMake: set policy version to prevent deprecation warnings. [PR #932](https://github.com/c-ares/c-ares/pull/932)
-* CMake: shared and static library names should be the same on unix platforms like autotools uses. [PR #933](https://github.com/c-ares/c-ares/pull/933)
-* Update to latest autoconf archive macros for enhanced system compatibility. [PR #936](https://github.com/c-ares/c-ares/pull/936)
+* A missing mutex initialization would make busy polling for configuration
+ changes (platforms other than Windows, Linux, MacOS) eat too much CPU
+ [PR #974](https://github.com/c-ares/c-ares/pull/974)
+* Pkgconfig may be generated wrong for static builds in relation to `-pthread`
+ [PR #965](https://github.com/c-ares/c-ares/pull/965)
+* Localhost resolution can fail if only one address family is in `/etc/hosts`
+ [PR #947](https://github.com/c-ares/c-ares/pull/947)
Thanks go to these friendly people for their efforts and contributions for this
release:
* Brad House (@bradh352)
-* Daniel Stenberg (@bagder)
-* Gregor Jasny (@gjasny)
-* @marcovsz
-* Nikolaos Chatzikonstantinou (@createyourpersonalaccount)
-* @vlasovsoft1979
+* Erik Lax (@eriklax)
+* Florian Pfisterer (@FlorianPfisterer)
+* Kai Pastor (@dg0yt)
+
diff --git a/contrib/libs/c-ares/include/ares_dns_record.h b/contrib/libs/c-ares/include/ares_dns_record.h
index 2896eab24b3..cec9f47f63d 100644
--- a/contrib/libs/c-ares/include/ares_dns_record.h
+++ b/contrib/libs/c-ares/include/ares_dns_record.h
@@ -1104,7 +1104,7 @@ CARES_EXTERN ares_status_t ares_dns_write(const ares_dns_record_t *dnsrec,
* (such as the ttl decrement capability).
*
* \param[in] dnsrec Pointer to initialized and filled DNS record object.
- * \return duplicted DNS record object, or NULL on out of memory.
+ * \return duplicated DNS record object, or NULL on out of memory.
*/
CARES_EXTERN ares_dns_record_t *
ares_dns_record_duplicate(const ares_dns_record_t *dnsrec);
diff --git a/contrib/libs/c-ares/include/ares_version.h b/contrib/libs/c-ares/include/ares_version.h
index 782046bd79d..7da82f2a15b 100644
--- a/contrib/libs/c-ares/include/ares_version.h
+++ b/contrib/libs/c-ares/include/ares_version.h
@@ -32,8 +32,8 @@
#define ARES_VERSION_MAJOR 1
#define ARES_VERSION_MINOR 34
-#define ARES_VERSION_PATCH 4
-#define ARES_VERSION_STR "1.34.4"
+#define ARES_VERSION_PATCH 5
+#define ARES_VERSION_STR "1.34.5"
/* NOTE: We cannot make the version string a C preprocessor stringify operation
* due to assumptions made by integrators that aren't properly using
diff --git a/contrib/libs/c-ares/src/lib/ares_addrinfo2hostent.c b/contrib/libs/c-ares/src/lib/ares_addrinfo2hostent.c
index 2bbc791157b..239ca5bce7d 100644
--- a/contrib/libs/c-ares/src/lib/ares_addrinfo2hostent.c
+++ b/contrib/libs/c-ares/src/lib/ares_addrinfo2hostent.c
@@ -47,119 +47,154 @@
# include <limits.h>
#endif
+static size_t hostent_nalias(const struct hostent *host)
+{
+ size_t i;
+ for (i=0; host->h_aliases != NULL && host->h_aliases[i] != NULL; i++)
+ ;
+
+ return i;
+}
+
+static size_t ai_nalias(const struct ares_addrinfo *ai)
+{
+ const struct ares_addrinfo_cname *cname;
+ size_t i = 0;
+
+ for (cname = ai->cnames; cname != NULL; cname=cname->next) {
+ i++;
+ }
+
+ return i;
+}
+
+static size_t hostent_naddr(const struct hostent *host)
+{
+ size_t i;
+ for (i=0; host->h_addr_list != NULL && host->h_addr_list[i] != NULL; i++)
+ ;
+
+ return i;
+}
+
+static size_t ai_naddr(const struct ares_addrinfo *ai, int af)
+{
+ const struct ares_addrinfo_node *node;
+ size_t i = 0;
+
+ for (node = ai->nodes; node != NULL; node=node->ai_next) {
+ if (af != AF_UNSPEC && af != node->ai_family)
+ continue;
+ i++;
+ }
+
+ return i;
+}
ares_status_t ares_addrinfo2hostent(const struct ares_addrinfo *ai, int family,
struct hostent **host)
{
struct ares_addrinfo_node *next;
- struct ares_addrinfo_cname *next_cname;
char **aliases = NULL;
- char *addrs = NULL;
+ char **addrs = NULL;
size_t naliases = 0;
size_t naddrs = 0;
- size_t alias = 0;
size_t i;
+ size_t ealiases = 0;
+ size_t eaddrs = 0;
if (ai == NULL || host == NULL) {
return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */
}
- /* Use the first node of the response as the family, since hostent can only
+ /* Use either the host set in the passed in hosts to be filled in, or the
+ * first node of the response as the family, since hostent can only
* represent one family. We assume getaddrinfo() returned a sorted list if
* the user requested AF_UNSPEC. */
- if (family == AF_UNSPEC && ai->nodes) {
- family = ai->nodes->ai_family;
+ if (family == AF_UNSPEC) {
+ if (*host != NULL && (*host)->h_addrtype != AF_UNSPEC) {
+ family = (*host)->h_addrtype;
+ } else if (ai->nodes != NULL) {
+ family = ai->nodes->ai_family;
+ }
}
if (family != AF_INET && family != AF_INET6) {
return ARES_EBADQUERY; /* LCOV_EXCL_LINE: DefensiveCoding */
}
- *host = ares_malloc(sizeof(**host));
- if (!(*host)) {
- goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
+ if (*host == NULL) {
+ *host = ares_malloc_zero(sizeof(**host));
+ if (!(*host)) {
+ goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
+ }
}
- memset(*host, 0, sizeof(**host));
- next = ai->nodes;
- while (next) {
- if (next->ai_family == family) {
- ++naddrs;
- }
- next = next->ai_next;
+ (*host)->h_addrtype = (HOSTENT_ADDRTYPE_TYPE)family;
+ if (family == AF_INET) {
+ (*host)->h_length = sizeof(struct in_addr);
+ } else if (family == AF_INET6) {
+ (*host)->h_length = sizeof(struct ares_in6_addr);
}
- next_cname = ai->cnames;
- while (next_cname) {
- if (next_cname->alias) {
- ++naliases;
+ if ((*host)->h_name == NULL) {
+ if (ai->cnames) {
+ (*host)->h_name = ares_strdup(ai->cnames->name);
+ if ((*host)->h_name == NULL && ai->cnames->name) {
+ goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
+ }
+ } else {
+ (*host)->h_name = ares_strdup(ai->name);
+ if ((*host)->h_name == NULL && ai->name) {
+ goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
+ }
}
- next_cname = next_cname->next;
}
- aliases = ares_malloc((naliases + 1) * sizeof(char *));
+ naliases = ai_nalias(ai);
+ ealiases = hostent_nalias(*host);
+ aliases = ares_realloc_zero((*host)->h_aliases,
+ ealiases * sizeof(char *),
+ (naliases + ealiases + 1) * sizeof(char *));
if (!aliases) {
goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
}
(*host)->h_aliases = aliases;
- memset(aliases, 0, (naliases + 1) * sizeof(char *));
if (naliases) {
- for (next_cname = ai->cnames; next_cname != NULL;
- next_cname = next_cname->next) {
- if (next_cname->alias == NULL) {
+ const struct ares_addrinfo_cname *cname;
+ i = ealiases;
+ for (cname = ai->cnames; cname != NULL; cname = cname->next) {
+ if (cname->alias == NULL) {
continue;
}
- aliases[alias] = ares_strdup(next_cname->alias);
- if (!aliases[alias]) {
+ (*host)->h_aliases[i] = ares_strdup(cname->alias);
+ if ((*host)->h_aliases[i] == NULL) {
goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
}
- alias++;
+ i++;
}
}
-
- (*host)->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *));
- if (!(*host)->h_addr_list) {
+ naddrs = ai_naddr(ai, family);
+ eaddrs = hostent_naddr(*host);
+ addrs = ares_realloc_zero((*host)->h_addr_list, eaddrs * sizeof(char *),
+ (naddrs + eaddrs + 1) * sizeof(char *));
+ if (addrs == NULL) {
goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
}
-
- memset((*host)->h_addr_list, 0, (naddrs + 1) * sizeof(char *));
-
- if (ai->cnames) {
- (*host)->h_name = ares_strdup(ai->cnames->name);
- if ((*host)->h_name == NULL && ai->cnames->name) {
- goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
- }
- } else {
- (*host)->h_name = ares_strdup(ai->name);
- if ((*host)->h_name == NULL && ai->name) {
- goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
- }
- }
-
- (*host)->h_addrtype = (HOSTENT_ADDRTYPE_TYPE)family;
-
- if (family == AF_INET) {
- (*host)->h_length = sizeof(struct in_addr);
- }
-
- if (family == AF_INET6) {
- (*host)->h_length = sizeof(struct ares_in6_addr);
- }
+ (*host)->h_addr_list = addrs;
if (naddrs) {
- addrs = ares_malloc(naddrs * (size_t)(*host)->h_length);
- if (!addrs) {
- goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
- }
-
- i = 0;
+ i = eaddrs;
for (next = ai->nodes; next != NULL; next = next->ai_next) {
if (next->ai_family != family) {
continue;
}
- (*host)->h_addr_list[i] = addrs + (i * (size_t)(*host)->h_length);
+ (*host)->h_addr_list[i] = ares_malloc_zero((size_t)(*host)->h_length);
+ if ((*host)->h_addr_list[i] == NULL) {
+ goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
+ }
if (family == AF_INET6) {
memcpy((*host)->h_addr_list[i],
&(CARES_INADDR_CAST(const struct sockaddr_in6 *, next->ai_addr)
@@ -172,15 +207,11 @@ ares_status_t ares_addrinfo2hostent(const struct ares_addrinfo *ai, int family,
->sin_addr),
(size_t)(*host)->h_length);
}
- ++i;
- }
-
- if (i == 0) {
- ares_free(addrs);
+ i++;
}
}
- if (naddrs == 0 && naliases == 0) {
+ if (naddrs + eaddrs == 0 && naliases + ealiases == 0) {
ares_free_hostent(*host);
*host = NULL;
return ARES_ENODATA;
diff --git a/contrib/libs/c-ares/src/lib/ares_addrinfo_localhost.c b/contrib/libs/c-ares/src/lib/ares_addrinfo_localhost.c
index 6f4f2a373b3..2abb0c48a6f 100644
--- a/contrib/libs/c-ares/src/lib/ares_addrinfo_localhost.c
+++ b/contrib/libs/c-ares/src/lib/ares_addrinfo_localhost.c
@@ -49,6 +49,19 @@
# endif
#endif
+static ares_bool_t ares_ai_has_family(int aftype,
+ const struct ares_addrinfo_node *nodes)
+{
+ const struct ares_addrinfo_node *node;
+
+ for (node = nodes; node != NULL; node = node->ai_next) {
+ if (node->ai_family == aftype)
+ return ARES_TRUE;
+ }
+
+ return ARES_FALSE;
+}
+
ares_status_t ares_append_ai_node(int aftype, unsigned short port,
unsigned int ttl, const void *adata,
struct ares_addrinfo_node **nodes)
@@ -107,7 +120,8 @@ static ares_status_t
{
ares_status_t status = ARES_SUCCESS;
- if (aftype == AF_UNSPEC || aftype == AF_INET6) {
+ if ((aftype == AF_UNSPEC || aftype == AF_INET6) &&
+ !ares_ai_has_family(AF_INET6, *nodes)) {
struct ares_in6_addr addr6;
ares_inet_pton(AF_INET6, "::1", &addr6);
status = ares_append_ai_node(AF_INET6, port, 0, &addr6, nodes);
@@ -116,7 +130,8 @@ static ares_status_t
}
}
- if (aftype == AF_UNSPEC || aftype == AF_INET) {
+ if ((aftype == AF_UNSPEC || aftype == AF_INET) &&
+ !ares_ai_has_family(AF_INET, *nodes)) {
struct in_addr addr4;
ares_inet_pton(AF_INET, "127.0.0.1", &addr4);
status = ares_append_ai_node(AF_INET, port, 0, &addr4, nodes);
@@ -150,11 +165,13 @@ static ares_status_t
continue;
}
- if (table->Table[i].Address.si_family == AF_INET) {
+ if (table->Table[i].Address.si_family == AF_INET &&
+ !ares_ai_has_family(AF_INET, *nodes)) {
status =
ares_append_ai_node(table->Table[i].Address.si_family, port, 0,
&table->Table[i].Address.Ipv4.sin_addr, nodes);
- } else if (table->Table[i].Address.si_family == AF_INET6) {
+ } else if (table->Table[i].Address.si_family == AF_INET6 &&
+ !ares_ai_has_family(AF_INET6, *nodes)) {
status =
ares_append_ai_node(table->Table[i].Address.si_family, port, 0,
&table->Table[i].Address.Ipv6.sin6_addr, nodes);
@@ -195,8 +212,7 @@ ares_status_t ares_addrinfo_localhost(const char *name, unsigned short port,
const struct ares_addrinfo_hints *hints,
struct ares_addrinfo *ai)
{
- struct ares_addrinfo_node *nodes = NULL;
- ares_status_t status;
+ ares_status_t status;
/* Validate family */
switch (hints->ai_family) {
@@ -208,26 +224,22 @@ ares_status_t ares_addrinfo_localhost(const char *name, unsigned short port,
return ARES_EBADFAMILY; /* LCOV_EXCL_LINE: DefensiveCoding */
}
+ if (ai->name != NULL) {
+ ares_free(ai->name);
+ }
ai->name = ares_strdup(name);
- if (!ai->name) {
- goto enomem; /* LCOV_EXCL_LINE: OutOfMemory */
+ if (ai->name == NULL) {
+ status = ARES_ENOMEM;
+ goto done; /* LCOV_EXCL_LINE: OutOfMemory */
}
- status = ares_system_loopback_addrs(hints->ai_family, port, &nodes);
-
- if (status == ARES_ENOTFOUND) {
- status = ares_default_loopback_addrs(hints->ai_family, port, &nodes);
+ status = ares_system_loopback_addrs(hints->ai_family, port, &ai->nodes);
+ if (status != ARES_SUCCESS && status != ARES_ENOTFOUND) {
+ goto done;
}
- ares_addrinfo_cat_nodes(&ai->nodes, nodes);
+ status = ares_default_loopback_addrs(hints->ai_family, port, &ai->nodes);
+done:
return status;
-
-/* LCOV_EXCL_START: OutOfMemory */
-enomem:
- ares_freeaddrinfo_nodes(nodes);
- ares_free(ai->name);
- ai->name = NULL;
- return ARES_ENOMEM;
- /* LCOV_EXCL_STOP */
}
diff --git a/contrib/libs/c-ares/src/lib/ares_close_sockets.c b/contrib/libs/c-ares/src/lib/ares_close_sockets.c
index fd3bf3c4b1e..347f43e6fcd 100644
--- a/contrib/libs/c-ares/src/lib/ares_close_sockets.c
+++ b/contrib/libs/c-ares/src/lib/ares_close_sockets.c
@@ -37,7 +37,7 @@ static void ares_requeue_queries(ares_conn_t *conn,
ares_tvnow(&now);
while ((query = ares_llist_first_val(conn->queries_to_conn)) != NULL) {
- ares_requeue_query(query, &now, requeue_status, ARES_TRUE, NULL);
+ ares_requeue_query(query, &now, requeue_status, ARES_TRUE, NULL, NULL);
}
}
diff --git a/contrib/libs/c-ares/src/lib/ares_config-linux.h b/contrib/libs/c-ares/src/lib/ares_config-linux.h
index 778bf91eeda..e0e7bd6c5fa 100644
--- a/contrib/libs/c-ares/src/lib/ares_config-linux.h
+++ b/contrib/libs/c-ares/src/lib/ares_config-linux.h
@@ -145,6 +145,9 @@
/* Define to 1 if you have the `if_nametoindex' function. */
#define HAVE_IF_NAMETOINDEX 1
+/* Define to 1 if you have the `GetBestRoute2' function. */
+/* #undef HAVE_GETBESTROUTE2 */
+
/* Define to 1 if you have the `ConvertInterfaceIndexToLuid' function. */
/* #undef HAVE_CONVERTINTERFACEINDEXTOLUID */
diff --git a/contrib/libs/c-ares/src/lib/ares_cookie.c b/contrib/libs/c-ares/src/lib/ares_cookie.c
index f31c74e748d..509e12050e0 100644
--- a/contrib/libs/c-ares/src/lib/ares_cookie.c
+++ b/contrib/libs/c-ares/src/lib/ares_cookie.c
@@ -115,7 +115,7 @@
* - If `cookie.unsupported_ts` evaluates less than
* `COOKIE_UNSUPPORTED_TIMEOUT`
* - Ensure there is no EDNS cookie opt (10) set (shouldn't be unless
- * requestor had put this themselves), then **skip any remaining
+ * requester had put this themselves), then **skip any remaining
* processing** as we don't want to try to send cookies.
* - Otherwise:
* - clear all cookie settings, set `cookie.state = INITIAL`.
@@ -369,7 +369,8 @@ ares_status_t ares_cookie_apply(ares_dns_record_t *dnsrec, ares_conn_t *conn,
ares_status_t ares_cookie_validate(ares_query_t *query,
const ares_dns_record_t *dnsresp,
- ares_conn_t *conn, const ares_timeval_t *now)
+ ares_conn_t *conn, const ares_timeval_t *now,
+ ares_array_t **requeue)
{
ares_server_t *server = conn->server;
ares_cookie_t *cookie = &server->cookie;
@@ -427,7 +428,8 @@ ares_status_t ares_cookie_validate(ares_query_t *query,
/* Resend the request, hopefully it will work the next time as we should
* have recorded a server cookie */
ares_requeue_query(query, now, ARES_SUCCESS,
- ARES_FALSE /* Don't increment try count */, NULL);
+ ARES_FALSE /* Don't increment try count */, NULL,
+ requeue);
/* Parent needs to drop this response */
return ARES_EBADRESP;
diff --git a/contrib/libs/c-ares/src/lib/ares_free_hostent.c b/contrib/libs/c-ares/src/lib/ares_free_hostent.c
index bf2037238b5..dfcbdf4910b 100644
--- a/contrib/libs/c-ares/src/lib/ares_free_hostent.c
+++ b/contrib/libs/c-ares/src/lib/ares_free_hostent.c
@@ -44,9 +44,10 @@ void ares_free_hostent(struct hostent *host)
}
ares_free(host->h_aliases);
if (host->h_addr_list) {
- ares_free(
- host->h_addr_list[0]); /* no matter if there is one or many entries,
- there is only one malloc for all of them */
+ size_t i;
+ for (i=0; host->h_addr_list[i] != NULL; i++) {
+ ares_free(host->h_addr_list[i]);
+ }
ares_free(host->h_addr_list);
}
ares_free(host);
diff --git a/contrib/libs/c-ares/src/lib/ares_getaddrinfo.c b/contrib/libs/c-ares/src/lib/ares_getaddrinfo.c
index 32791dc37dc..eabd17fcbac 100644
--- a/contrib/libs/c-ares/src/lib/ares_getaddrinfo.c
+++ b/contrib/libs/c-ares/src/lib/ares_getaddrinfo.c
@@ -418,9 +418,13 @@ done:
* SHOULD recognize localhost names as special and SHOULD always return the
* IP loopback address for address queries".
* We will also ignore ALL errors when trying to resolve localhost, such
- * as permissions errors reading /etc/hosts or a malformed /etc/hosts */
- if (status != ARES_SUCCESS && status != ARES_ENOMEM &&
- ares_is_localhost(hquery->name)) {
+ * as permissions errors reading /etc/hosts or a malformed /etc/hosts.
+ *
+ * Also, just because the query itself returned success from /etc/hosts
+ * lookup doesn't mean it returned everything it needed to for all requested
+ * address families. As long as we're not on a critical out of memory
+ * condition pass it through to fill in any other address classes. */
+ if (status != ARES_ENOMEM && ares_is_localhost(hquery->name)) {
return ares_addrinfo_localhost(hquery->name, hquery->port, &hquery->hints,
hquery->ai);
}
diff --git a/contrib/libs/c-ares/src/lib/ares_gethostbyaddr.c b/contrib/libs/c-ares/src/lib/ares_gethostbyaddr.c
index a7acf3c45c9..69c509ab11b 100644
--- a/contrib/libs/c-ares/src/lib/ares_gethostbyaddr.c
+++ b/contrib/libs/c-ares/src/lib/ares_gethostbyaddr.c
@@ -120,7 +120,7 @@ static void next_lookup(struct addr_query *aquery)
{
const char *p;
ares_status_t status;
- struct hostent *host;
+ struct hostent *host = NULL;
char *name;
for (p = aquery->remaining_lookups; *p; p++) {
diff --git a/contrib/libs/c-ares/src/lib/ares_gethostbyname.c b/contrib/libs/c-ares/src/lib/ares_gethostbyname.c
index 56de729526a..d451b468511 100644
--- a/contrib/libs/c-ares/src/lib/ares_gethostbyname.c
+++ b/contrib/libs/c-ares/src/lib/ares_gethostbyname.c
@@ -287,6 +287,8 @@ static ares_status_t ares_gethostbyname_file_int(ares_channel_t *channel,
return ARES_ENOTFOUND;
}
+ *host = NULL;
+
/* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */
if (ares_is_onion_domain(name)) {
return ARES_ENOTFOUND;
@@ -307,9 +309,13 @@ done:
* SHOULD recognize localhost names as special and SHOULD always return the
* IP loopback address for address queries".
* We will also ignore ALL errors when trying to resolve localhost, such
- * as permissions errors reading /etc/hosts or a malformed /etc/hosts */
- if (status != ARES_SUCCESS && status != ARES_ENOMEM &&
- ares_is_localhost(name)) {
+ * as permissions errors reading /etc/hosts or a malformed /etc/hosts.
+ *
+ * Also, just because the query itself returned success from /etc/hosts
+ * lookup doesn't mean it returned everything it needed to for all requested
+ * address families. As long as we're not on a critical out of memory
+ * condition pass it through to fill in any other address classes. */
+ if (status != ARES_ENOMEM && ares_is_localhost(name)) {
return ares_hostent_localhost(name, family, host);
}
diff --git a/contrib/libs/c-ares/src/lib/ares_hosts_file.c b/contrib/libs/c-ares/src/lib/ares_hosts_file.c
index 0439b8e1d47..d18863b8f66 100644
--- a/contrib/libs/c-ares/src/lib/ares_hosts_file.c
+++ b/contrib/libs/c-ares/src/lib/ares_hosts_file.c
@@ -845,7 +845,7 @@ ares_status_t ares_hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry,
ares_bool_t want_cnames,
struct ares_addrinfo *ai)
{
- ares_status_t status;
+ ares_status_t status = ARES_ENOTFOUND;
struct ares_addrinfo_cname *cnames = NULL;
struct ares_addrinfo_node *ainodes = NULL;
ares_llist_node_t *node;
@@ -860,6 +860,7 @@ ares_status_t ares_hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry,
}
if (name != NULL) {
+ ares_free(ai->name);
ai->name = ares_strdup(name);
if (ai->name == NULL) {
status = ARES_ENOMEM; /* LCOV_EXCL_LINE: OutOfMemory */
@@ -888,6 +889,11 @@ ares_status_t ares_hosts_entry_to_addrinfo(const ares_hosts_entry_t *entry,
}
}
+ /* Might be ARES_ENOTFOUND here if no ips matched requested address family */
+ if (status != ARES_SUCCESS) {
+ goto done;
+ }
+
if (want_cnames) {
status = ares_hosts_ai_append_cnames(entry, &cnames);
if (status != ARES_SUCCESS) {
diff --git a/contrib/libs/c-ares/src/lib/ares_ipv6.h b/contrib/libs/c-ares/src/lib/ares_ipv6.h
index 5da341b0106..d2007cc29ec 100644
--- a/contrib/libs/c-ares/src/lib/ares_ipv6.h
+++ b/contrib/libs/c-ares/src/lib/ares_ipv6.h
@@ -90,6 +90,16 @@ struct addrinfo {
# define NS_INT16SZ 2
#endif
+/* Windows XP Compatibility with later MSVC/Mingw versions */
+#if defined(_WIN32)
+# if !defined(IF_MAX_STRING_SIZE)
+# define IF_MAX_STRING_SIZE 256 /* =256 in <ifdef.h> */
+# endif
+# if !defined(NDIS_IF_MAX_STRING_SIZE)
+# define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE /* =256 in <ifdef.h> */
+# endif
+#endif
+
#ifndef IF_NAMESIZE
# ifdef IFNAMSIZ
# define IF_NAMESIZE IFNAMSIZ
diff --git a/contrib/libs/c-ares/src/lib/ares_metrics.c b/contrib/libs/c-ares/src/lib/ares_metrics.c
index 13e34decc06..deb3b7febcc 100644
--- a/contrib/libs/c-ares/src/lib/ares_metrics.c
+++ b/contrib/libs/c-ares/src/lib/ares_metrics.c
@@ -197,7 +197,7 @@ void ares_metrics_record(const ares_query_t *query, ares_server_t *server,
}
if (query_ms > server->metrics[i].latency_max_ms) {
- server->metrics[i].latency_min_ms = query_ms;
+ server->metrics[i].latency_max_ms = query_ms;
}
server->metrics[i].total_count++;
diff --git a/contrib/libs/c-ares/src/lib/ares_private.h b/contrib/libs/c-ares/src/lib/ares_private.h
index e6d44e8b864..3d7cea3d3a0 100644
--- a/contrib/libs/c-ares/src/lib/ares_private.h
+++ b/contrib/libs/c-ares/src/lib/ares_private.h
@@ -321,7 +321,8 @@ ares_status_t ares_send_query(ares_server_t *requested_server /* Optional */,
ares_status_t ares_requeue_query(ares_query_t *query, const ares_timeval_t *now,
ares_status_t status,
ares_bool_t inc_try_count,
- const ares_dns_record_t *dnsrec);
+ const ares_dns_record_t *dnsrec,
+ ares_array_t **requeue);
/*! Count the number of labels (dots+1) in a domain */
size_t ares_name_label_cnt(const char *name);
@@ -455,8 +456,10 @@ ares_status_t ares_parse_ptr_reply_dnsrec(const ares_dns_record_t *dnsrec,
const void *addr, int addrlen,
int family, struct hostent **host);
+/* host address must be valid or NULL as will create or append */
ares_status_t ares_addrinfo2hostent(const struct ares_addrinfo *ai, int family,
struct hostent **host);
+
ares_status_t ares_addrinfo2addrttl(const struct ares_addrinfo *ai, int family,
size_t req_naddrttls,
struct ares_addrttl *addrttls,
@@ -610,7 +613,8 @@ ares_status_t ares_cookie_apply(ares_dns_record_t *dnsrec, ares_conn_t *conn,
ares_status_t ares_cookie_validate(ares_query_t *query,
const ares_dns_record_t *dnsresp,
ares_conn_t *conn,
- const ares_timeval_t *now);
+ const ares_timeval_t *now,
+ ares_array_t **requeue);
ares_status_t ares_channel_threading_init(ares_channel_t *channel);
void ares_channel_threading_destroy(ares_channel_t *channel);
diff --git a/contrib/libs/c-ares/src/lib/ares_process.c b/contrib/libs/c-ares/src/lib/ares_process.c
index 3d186ea9d58..c5834fa100e 100644
--- a/contrib/libs/c-ares/src/lib/ares_process.c
+++ b/contrib/libs/c-ares/src/lib/ares_process.c
@@ -56,7 +56,8 @@ static ares_status_t process_timeouts(ares_channel_t *channel,
static ares_status_t process_answer(ares_channel_t *channel,
const unsigned char *abuf, size_t alen,
ares_conn_t *conn,
- const ares_timeval_t *now);
+ const ares_timeval_t *now,
+ ares_array_t **requeue);
static void handle_conn_error(ares_conn_t *conn, ares_bool_t critical_failure,
ares_status_t failure_status);
static ares_bool_t same_questions(const ares_query_t *query,
@@ -510,10 +511,38 @@ static ares_status_t read_conn_packets(ares_conn_t *conn)
return ARES_SUCCESS;
}
+/* Simple data structure to store a query that needs to be requeued with
+ * optional server */
+typedef struct {
+ unsigned short qid;
+ ares_server_t *server; /* optional */
+} ares_requeue_t;
+
+static ares_status_t ares_append_requeue(ares_array_t **requeue,
+ ares_query_t *query,
+ ares_server_t *server)
+{
+ ares_requeue_t entry;
+
+ if (*requeue == NULL) {
+ *requeue = ares_array_create(sizeof(ares_requeue_t), NULL);
+ if (*requeue == NULL) {
+ return ARES_ENOMEM;
+ }
+ }
+
+ ares_query_remove_from_conn(query);
+
+ entry.qid = query->qid;
+ entry.server = server;
+ return ares_array_insertdata_last(*requeue, &entry);
+}
+
static ares_status_t read_answers(ares_conn_t *conn, const ares_timeval_t *now)
{
ares_status_t status;
ares_channel_t *channel = conn->server->channel;
+ ares_array_t *requeue = NULL;
/* Process all queued answers */
while (1) {
@@ -550,15 +579,43 @@ static ares_status_t read_answers(ares_conn_t *conn, const ares_timeval_t *now)
data_len -= 2;
/* We finished reading this answer; process it */
- status = process_answer(channel, data, data_len, conn, now);
+ status = process_answer(channel, data, data_len, conn, now, &requeue);
if (status != ARES_SUCCESS) {
handle_conn_error(conn, ARES_TRUE, status);
- return status;
+ goto cleanup;
}
/* Since we processed the answer, clear the tag so space can be reclaimed */
ares_buf_tag_clear(conn->in_buf);
}
+
+cleanup:
+
+ /* Flush requeue */
+ while (ares_array_len(requeue) > 0) {
+ ares_query_t *query;
+ ares_requeue_t entry;
+ ares_status_t internal_status;
+
+ internal_status = ares_array_claim_at(&entry, sizeof(entry), requeue, 0);
+ if (internal_status != ARES_SUCCESS) {
+ break;
+ }
+
+ /* Query disappeared */
+ query = ares_htable_szvp_get_direct(channel->queries_by_qid, entry.qid);
+ if (query == NULL) {
+ continue;
+ }
+
+ internal_status = ares_send_query(entry.server, query, now);
+ /* We only care about ARES_ENOMEM */
+ if (internal_status == ARES_ENOMEM) {
+ status = ARES_ENOMEM;
+ }
+ }
+ ares_array_destroy(requeue);
+
return status;
}
@@ -611,7 +668,8 @@ static ares_status_t process_timeouts(ares_channel_t *channel,
conn = query->conn;
server_increment_failures(conn->server, query->using_tcp);
- status = ares_requeue_query(query, now, ARES_ETIMEOUT, ARES_TRUE, NULL);
+ status = ares_requeue_query(query, now, ARES_ETIMEOUT, ARES_TRUE, NULL,
+ NULL);
if (status == ARES_ENOMEM) {
goto done;
}
@@ -701,7 +759,8 @@ static ares_bool_t issue_might_be_edns(const ares_dns_record_t *req,
static ares_status_t process_answer(ares_channel_t *channel,
const unsigned char *abuf, size_t alen,
ares_conn_t *conn,
- const ares_timeval_t *now)
+ const ares_timeval_t *now,
+ ares_array_t **requeue)
{
ares_query_t *query;
/* Cache these as once ares_send_query() gets called, it may end up
@@ -745,7 +804,8 @@ static ares_status_t process_answer(ares_channel_t *channel,
/* Validate DNS cookie in response. This function may need to requeue the
* query. */
- if (ares_cookie_validate(query, rdnsrec, conn, now) != ARES_SUCCESS) {
+ if (ares_cookie_validate(query, rdnsrec, conn, now, requeue)
+ != ARES_SUCCESS) {
/* Drop response and return */
status = ARES_SUCCESS;
goto cleanup;
@@ -768,9 +828,8 @@ static ares_status_t process_answer(ares_channel_t *channel,
goto cleanup;
}
- /* Send to same server */
- ares_send_query(server, query, now);
- status = ARES_SUCCESS;
+ /* Requeue to same server */
+ status = ares_append_requeue(requeue, query, server);
goto cleanup;
}
@@ -782,8 +841,9 @@ static ares_status_t process_answer(ares_channel_t *channel,
!(conn->flags & ARES_CONN_FLAG_TCP) &&
!(channel->flags & ARES_FLAG_IGNTC)) {
query->using_tcp = ARES_TRUE;
- ares_send_query(NULL, query, now);
- status = ARES_SUCCESS; /* Switched to TCP is ok */
+ status = ares_append_requeue(requeue, query, NULL);
+ /* Status will reflect success except on memory error, which is good since
+ * requeuing to TCP is ok */
goto cleanup;
}
@@ -809,11 +869,13 @@ static ares_status_t process_answer(ares_channel_t *channel,
}
server_increment_failures(server, query->using_tcp);
- ares_requeue_query(query, now, status, ARES_TRUE, rdnsrec);
+ status = ares_requeue_query(query, now, status, ARES_TRUE, rdnsrec, requeue);
- /* Should any of these cause a connection termination?
- * Maybe SERVER_FAILURE? */
- status = ARES_SUCCESS;
+ if (status != ARES_ENOMEM) {
+ /* Should any of these cause a connection termination?
+ * Maybe SERVER_FAILURE? */
+ status = ARES_SUCCESS;
+ }
goto cleanup;
}
}
@@ -854,10 +916,14 @@ static void handle_conn_error(ares_conn_t *conn, ares_bool_t critical_failure,
ares_close_connection(conn, failure_status);
}
+/* Requeue query will normally call ares_send_query() but in some circumstances
+ * this needs to be delayed, so if requeue is not NULL, it will add the query
+ * to the queue instead */
ares_status_t ares_requeue_query(ares_query_t *query, const ares_timeval_t *now,
ares_status_t status,
ares_bool_t inc_try_count,
- const ares_dns_record_t *dnsrec)
+ const ares_dns_record_t *dnsrec,
+ ares_array_t **requeue)
{
ares_channel_t *channel = query->channel;
size_t max_tries = ares_slist_len(channel->servers) * channel->tries;
@@ -873,6 +939,9 @@ ares_status_t ares_requeue_query(ares_query_t *query, const ares_timeval_t *now,
}
if (query->try_count < max_tries && !query->no_retries) {
+ if (requeue != NULL) {
+ return ares_append_requeue(requeue, query, NULL);
+ }
return ares_send_query(NULL, query, now);
}
@@ -1187,7 +1256,7 @@ ares_status_t ares_send_query(ares_server_t *requested_server,
case ARES_ECONNREFUSED:
case ARES_EBADFAMILY:
server_increment_failures(server, query->using_tcp);
- return ares_requeue_query(query, now, status, ARES_TRUE, NULL);
+ return ares_requeue_query(query, now, status, ARES_TRUE, NULL, NULL);
/* Anything else is not retryable, likely ENOMEM */
default:
@@ -1213,7 +1282,7 @@ ares_status_t ares_send_query(ares_server_t *requested_server,
case ARES_ECONNREFUSED:
case ARES_EBADFAMILY:
handle_conn_error(conn, ARES_TRUE, status);
- status = ares_requeue_query(query, now, status, ARES_TRUE, NULL);
+ status = ares_requeue_query(query, now, status, ARES_TRUE, NULL, NULL);
if (status == ARES_ETIMEOUT) {
status = ARES_ECONNREFUSED;
}
@@ -1221,7 +1290,7 @@ ares_status_t ares_send_query(ares_server_t *requested_server,
default:
server_increment_failures(server, query->using_tcp);
- status = ares_requeue_query(query, now, status, ARES_TRUE, NULL);
+ status = ares_requeue_query(query, now, status, ARES_TRUE, NULL, NULL);
return status;
}
diff --git a/contrib/libs/c-ares/src/lib/ares_sysconfig_win.c b/contrib/libs/c-ares/src/lib/ares_sysconfig_win.c
index f6e07f92e47..01109a89ba4 100644
--- a/contrib/libs/c-ares/src/lib/ares_sysconfig_win.c
+++ b/contrib/libs/c-ares/src/lib/ares_sysconfig_win.c
@@ -176,6 +176,7 @@ static int compareAddresses(const void *arg1, const void *arg2)
return 0;
}
+#if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__)
/* There can be multiple routes to "the Internet". And there can be different
* DNS servers associated with each of the interfaces that offer those routes.
* We have to assume that any DNS server can serve any request. But, some DNS
@@ -213,18 +214,6 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */
const SOCKADDR_INET * const dest,
const ULONG interfaceMetric)
{
- /* On this interface, get the best route to that destination. */
-# if defined(__WATCOMC__)
- /* OpenWatcom's builtin Windows SDK does not have a definition for
- * MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET
- * as a variable. Let's work around this by returning the worst possible
- * metric, but only when using the OpenWatcom compiler.
- * It may be worth investigating using a different version of the Windows
- * SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom
- * 2.0.
- */
- return (ULONG)-1;
-# else
MIB_IPFORWARD_ROW2 row;
SOCKADDR_INET ignored;
if (GetBestRoute2(/* The interface to use. The index is ignored since we are
@@ -257,8 +246,8 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */
* which describes the combination as a "sum".
*/
return row.Metric + interfaceMetric;
-# endif /* __WATCOMC__ */
}
+#endif
/*
* get_DNS_Windows()
@@ -379,9 +368,21 @@ static ares_bool_t get_DNS_Windows(char **outptr)
addressesSize = newSize;
}
+# if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__)
+ /* OpenWatcom's builtin Windows SDK does not have a definition for
+ * MIB_IPFORWARD_ROW2, and also does not allow the usage of SOCKADDR_INET
+ * as a variable. Let's work around this by returning the worst possible
+ * metric, but only when using the OpenWatcom compiler.
+ * It may be worth investigating using a different version of the Windows
+ * SDK with OpenWatcom in the future, though this may be fixed in OpenWatcom
+ * 2.0.
+ */
addresses[addressesIndex].metric = getBestRouteMetric(
&ipaaEntry->Luid, (SOCKADDR_INET *)((void *)(namesrvr.sa)),
ipaaEntry->Ipv4Metric);
+# else
+ addresses[addressesIndex].metric = (ULONG)-1;
+# endif
/* Record insertion index to make qsort stable */
addresses[addressesIndex].orig_idx = addressesIndex;
@@ -423,9 +424,13 @@ static ares_bool_t get_DNS_Windows(char **outptr)
ll_scope = ipaaEntry->Ipv6IfIndex;
}
+# if defined(HAVE_GETBESTROUTE2) && !defined(__WATCOMC__)
addresses[addressesIndex].metric = getBestRouteMetric(
&ipaaEntry->Luid, (SOCKADDR_INET *)((void *)(namesrvr.sa)),
ipaaEntry->Ipv6Metric);
+# else
+ addresses[addressesIndex].metric = (ULONG)-1;
+# endif
/* Record insertion index to make qsort stable */
addresses[addressesIndex].orig_idx = addressesIndex;
diff --git a/contrib/libs/c-ares/src/lib/config-win32.h b/contrib/libs/c-ares/src/lib/config-win32.h
index 62f8f6f2679..f3da8e62b8e 100644
--- a/contrib/libs/c-ares/src/lib/config-win32.h
+++ b/contrib/libs/c-ares/src/lib/config-win32.h
@@ -243,8 +243,10 @@
# undef HAVE_NETIOAPI_H
#endif
-/* Threading support enabled */
-#define CARES_THREADS 1
+/* Threading support enabled for Vista+ */
+#if !defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0600
+# define CARES_THREADS 1
+#endif
/* ---------------------------------------------------------------- */
/* TYPEDEF REPLACEMENTS */
@@ -376,6 +378,8 @@
# define HAVE_CONVERTINTERFACELUIDTONAMEA 1
/* Define to 1 if you have the `NotifyIpInterfaceChange' function. */
# define HAVE_NOTIFYIPINTERFACECHANGE 1
+/* Define to 1 if you have the `GetBestRoute2` function */
+# define HAVE_GETBESTROUTE2 1
#endif
/* ---------------------------------------------------------------- */
diff --git a/contrib/libs/c-ares/src/lib/event/ares_event.h b/contrib/libs/c-ares/src/lib/event/ares_event.h
index 36cd10dcf89..bf298dfb619 100644
--- a/contrib/libs/c-ares/src/lib/event/ares_event.h
+++ b/contrib/libs/c-ares/src/lib/event/ares_event.h
@@ -159,30 +159,33 @@ ares_status_t ares_event_update(ares_event_t **event, ares_event_thread_t *e,
ares_event_signal_cb_t signal_cb);
-#ifdef HAVE_PIPE
+#ifdef CARES_THREADS
+# ifdef HAVE_PIPE
ares_event_t *ares_pipeevent_create(ares_event_thread_t *e);
-#endif
+# endif
-#ifdef HAVE_POLL
+# ifdef HAVE_POLL
extern const ares_event_sys_t ares_evsys_poll;
-#endif
+# endif
-#ifdef HAVE_KQUEUE
+# ifdef HAVE_KQUEUE
extern const ares_event_sys_t ares_evsys_kqueue;
-#endif
+# endif
-#ifdef HAVE_EPOLL
+# ifdef HAVE_EPOLL
extern const ares_event_sys_t ares_evsys_epoll;
-#endif
+# endif
-#ifdef _WIN32
+# ifdef _WIN32
extern const ares_event_sys_t ares_evsys_win32;
-#endif
+# endif
/* All systems have select(), but not all have a way to wake, so we require
* pipe() to wake the select() */
-#ifdef HAVE_PIPE
+# ifdef HAVE_PIPE
extern const ares_event_sys_t ares_evsys_select;
+# endif
+
#endif
#endif
diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_configchg.c b/contrib/libs/c-ares/src/lib/event/ares_event_configchg.c
index 5ecc6888ab7..2a8c780c2cc 100644
--- a/contrib/libs/c-ares/src/lib/event/ares_event_configchg.c
+++ b/contrib/libs/c-ares/src/lib/event/ares_event_configchg.c
@@ -26,7 +26,7 @@
#include "ares_private.h"
#include "ares_event.h"
-#ifdef __ANDROID__
+#if defined(__ANDROID__) && defined(CARES_THREADS)
ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
ares_event_thread_t *e)
@@ -43,7 +43,7 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg)
(void)configchg;
}
-#elif defined(__linux__)
+#elif defined(__linux__) && defined(CARES_THREADS)
# include <sys/inotify.h>
@@ -174,7 +174,7 @@ done:
return status;
}
-#elif defined(USE_WINSOCK)
+#elif defined(USE_WINSOCK) && defined(CARES_THREADS)
# include <winsock2.h>
# include <iphlpapi.h>
@@ -379,7 +379,7 @@ done:
return status;
}
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) && defined(CARES_THREADS)
# include <sys/types.h>
# include <unistd.h>
@@ -531,7 +531,7 @@ done:
return status;
}
-#elif defined(HAVE_STAT) && !defined(_WIN32)
+#elif defined(HAVE_STAT) && !defined(_WIN32) && defined(CARES_THREADS)
# ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
# endif
@@ -665,6 +665,12 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
goto done;
}
+ c->lock = ares_thread_mutex_create();
+ if (c->lock == NULL) {
+ status = ARES_ENOMEM;
+ goto done;
+ }
+
c->resolvconf_path = c->e->channel->resolvconf_path;
if (c->resolvconf_path == NULL) {
c->resolvconf_path = PATH_RESOLV_CONF;
@@ -722,6 +728,8 @@ void ares_event_configchg_destroy(ares_event_configchg_t *configchg)
ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
ares_event_thread_t *e)
{
+ (void)configchg;
+ (void)e;
/* No ability */
return ARES_ENOTIMP;
}
@@ -729,6 +737,7 @@ ares_status_t ares_event_configchg_init(ares_event_configchg_t **configchg,
void ares_event_configchg_destroy(ares_event_configchg_t *configchg)
{
/* No-op */
+ (void)configchg;
}
#endif
diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_epoll.c b/contrib/libs/c-ares/src/lib/event/ares_event_epoll.c
index 538c38b4f94..d451c86a3d5 100644
--- a/contrib/libs/c-ares/src/lib/event/ares_event_epoll.c
+++ b/contrib/libs/c-ares/src/lib/event/ares_event_epoll.c
@@ -26,6 +26,8 @@
#include "ares_private.h"
#include "ares_event.h"
+#if defined(HAVE_EPOLL) && defined(CARES_THREADS)
+
#ifdef HAVE_SYS_EPOLL_H
# include <sys/epoll.h>
#endif
@@ -33,8 +35,6 @@
# include <fcntl.h>
#endif
-#ifdef HAVE_EPOLL
-
typedef struct {
int epoll_fd;
} ares_evsys_epoll_t;
diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_kqueue.c b/contrib/libs/c-ares/src/lib/event/ares_event_kqueue.c
index dbbd0dbd9f7..00cdcbe9c2a 100644
--- a/contrib/libs/c-ares/src/lib/event/ares_event_kqueue.c
+++ b/contrib/libs/c-ares/src/lib/event/ares_event_kqueue.c
@@ -26,6 +26,8 @@
#include "ares_private.h"
#include "ares_event.h"
+#if defined(HAVE_KQUEUE) && defined(CARES_THREADS)
+
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
@@ -39,8 +41,6 @@
# include <fcntl.h>
#endif
-#ifdef HAVE_KQUEUE
-
typedef struct {
int kqueue_fd;
struct kevent *changelist;
diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_poll.c b/contrib/libs/c-ares/src/lib/event/ares_event_poll.c
index c6ab4b62072..28e3c096576 100644
--- a/contrib/libs/c-ares/src/lib/event/ares_event_poll.c
+++ b/contrib/libs/c-ares/src/lib/event/ares_event_poll.c
@@ -25,12 +25,13 @@
*/
#include "ares_private.h"
#include "ares_event.h"
+
+#if defined(HAVE_POLL) && defined(CARES_THREADS)
+
#ifdef HAVE_POLL_H
# include <poll.h>
#endif
-#if defined(HAVE_POLL)
-
static ares_bool_t ares_evsys_poll_init(ares_event_thread_t *e)
{
e->ev_signal = ares_pipeevent_create(e);
diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_select.c b/contrib/libs/c-ares/src/lib/event/ares_event_select.c
index 4d7c085d872..df758b5a1e5 100644
--- a/contrib/libs/c-ares/src/lib/event/ares_event_select.c
+++ b/contrib/libs/c-ares/src/lib/event/ares_event_select.c
@@ -31,13 +31,14 @@
#include "ares_private.h"
#include "ares_event.h"
-#ifdef HAVE_SYS_SELECT_H
-# include <sys/select.h>
-#endif
/* All systems have select(), but not all have a way to wake, so we require
* pipe() to wake the select() */
-#if defined(HAVE_PIPE)
+#if defined(HAVE_PIPE) && defined(CARES_THREADS)
+
+#ifdef HAVE_SYS_SELECT_H
+# include <sys/select.h>
+#endif
static ares_bool_t ares_evsys_select_init(ares_event_thread_t *e)
{
diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_thread.c b/contrib/libs/c-ares/src/lib/event/ares_event_thread.c
index d59b7880a41..c77514e02c1 100644
--- a/contrib/libs/c-ares/src/lib/event/ares_event_thread.c
+++ b/contrib/libs/c-ares/src/lib/event/ares_event_thread.c
@@ -26,6 +26,7 @@
#include "ares_private.h"
#include "ares_event.h"
+#ifdef CARES_THREADS
static void ares_event_destroy_cb(void *arg)
{
ares_event_t *event = arg;
@@ -549,3 +550,18 @@ ares_status_t ares_event_thread_init(ares_channel_t *channel)
return ARES_SUCCESS;
}
+
+#else
+
+ares_status_t ares_event_thread_init(ares_channel_t *channel)
+{
+ (void)channel;
+ return ARES_ENOTIMP;
+}
+
+void ares_event_thread_destroy(ares_channel_t *channel)
+{
+ (void)channel;
+}
+
+#endif
diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_wake_pipe.c b/contrib/libs/c-ares/src/lib/event/ares_event_wake_pipe.c
index d3b166a3d6c..cd1534bbbd5 100644
--- a/contrib/libs/c-ares/src/lib/event/ares_event_wake_pipe.c
+++ b/contrib/libs/c-ares/src/lib/event/ares_event_wake_pipe.c
@@ -25,14 +25,16 @@
*/
#include "ares_private.h"
#include "ares_event.h"
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-#ifdef HAVE_FCNTL_H
-# include <fcntl.h>
-#endif
-#ifdef HAVE_PIPE
+#if defined(HAVE_PIPE) && defined(CARES_THREADS)
+
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+# ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+# endif
+
typedef struct {
int filedes[2];
} ares_pipeevent_t;
diff --git a/contrib/libs/c-ares/src/lib/event/ares_event_win32.c b/contrib/libs/c-ares/src/lib/event/ares_event_win32.c
index 1531b6d81dd..d7d1d657350 100644
--- a/contrib/libs/c-ares/src/lib/event/ares_event_win32.c
+++ b/contrib/libs/c-ares/src/lib/event/ares_event_win32.c
@@ -37,12 +37,14 @@
#include "ares_private.h"
#include "ares_event.h"
#include "ares_event_win32.h"
+
+
+#if defined(USE_WINSOCK) && defined(CARES_THREADS)
+
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
-#if defined(USE_WINSOCK)
-
/* IMPLEMENTATION NOTES
* ====================
*
@@ -667,7 +669,7 @@ static ares_bool_t ares_evsys_win32_afd_cancel(ares_evsys_win32_eventdata_t *ed)
/* NtCancelIoFileEx() may return STATUS_NOT_FOUND if the operation completed
* just before calling NtCancelIoFileEx(), but we have not yet received the
- * notifiction (but it should be queued for the next IOCP event). */
+ * notification (but it should be queued for the next IOCP event). */
if (status == STATUS_SUCCESS || status == STATUS_NOT_FOUND) {
return ARES_TRUE;
}
diff --git a/contrib/libs/c-ares/src/lib/legacy/ares_parse_a_reply.c b/contrib/libs/c-ares/src/lib/legacy/ares_parse_a_reply.c
index 870aaccf76c..9fd4a07ac0f 100644
--- a/contrib/libs/c-ares/src/lib/legacy/ares_parse_a_reply.c
+++ b/contrib/libs/c-ares/src/lib/legacy/ares_parse_a_reply.c
@@ -77,6 +77,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
}
if (host != NULL) {
+ *host = NULL;
status = ares_addrinfo2hostent(&ai, AF_INET, host);
if (status != ARES_SUCCESS && status != ARES_ENODATA) {
goto fail; /* LCOV_EXCL_LINE: DefensiveCoding */
diff --git a/contrib/libs/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c b/contrib/libs/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c
index 278642f0b3e..4c177ec9cbb 100644
--- a/contrib/libs/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c
+++ b/contrib/libs/c-ares/src/lib/legacy/ares_parse_aaaa_reply.c
@@ -80,6 +80,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
}
if (host != NULL) {
+ *host = NULL;
status = ares_addrinfo2hostent(&ai, AF_INET6, host);
if (status != ARES_SUCCESS && status != ARES_ENODATA) {
goto fail; /* LCOV_EXCL_LINE: DefensiveCoding */
diff --git a/contrib/libs/c-ares/src/lib/util/ares_iface_ips.c b/contrib/libs/c-ares/src/lib/util/ares_iface_ips.c
index 46cb291e300..c5f507f87e1 100644
--- a/contrib/libs/c-ares/src/lib/util/ares_iface_ips.c
+++ b/contrib/libs/c-ares/src/lib/util/ares_iface_ips.c
@@ -431,8 +431,14 @@ static ares_status_t ares_iface_ips_enumerate(ares_iface_ips_t *ips,
}
status = ares_iface_ips_add(ips, addrflag, ifname, &addr,
+#if _WIN32_WINNT >= 0x0600
ipaddr->OnLinkPrefixLength /* netmask */,
- address->Ipv6IfIndex /* ll_scope */);
+#else
+ ipaddr->Address.lpSockaddr->sa_family
+ == AF_INET?32:128,
+#endif
+ address->Ipv6IfIndex /* ll_scope */
+ );
if (status != ARES_SUCCESS) {
goto done;
diff --git a/contrib/libs/c-ares/src/lib/util/ares_uri.h b/contrib/libs/c-ares/src/lib/util/ares_uri.h
index 6a703cba5b5..2d8138fdc3e 100644
--- a/contrib/libs/c-ares/src/lib/util/ares_uri.h
+++ b/contrib/libs/c-ares/src/lib/util/ares_uri.h
@@ -175,7 +175,7 @@ ares_status_t ares_uri_set_query_key(ares_uri_t *uri, const char *key,
*/
ares_status_t ares_uri_del_query_key(ares_uri_t *uri, const char *key);
-/*! Retrieve the value associted with a query key. Keys are case-insensitive.
+/*! Retrieve the value associated with a query key. Keys are case-insensitive.
*
* \param[in] uri Initialized URI object
* \param[in] key Key to retrieve.
diff --git a/contrib/libs/c-ares/ya.make b/contrib/libs/c-ares/ya.make
index a49eb6942f6..9ead6c9763d 100644
--- a/contrib/libs/c-ares/ya.make
+++ b/contrib/libs/c-ares/ya.make
@@ -12,9 +12,9 @@ LICENSE(
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
-VERSION(1.34.4)
+VERSION(1.34.5)
-ORIGINAL_SOURCE(https://github.com/c-ares/c-ares/archive/v1.34.4.tar.gz)
+ORIGINAL_SOURCE(https://github.com/c-ares/c-ares/archive/v1.34.5.tar.gz)
PEERDIR(
contrib/libs/libc_compat