Skip to content

Commit 4ae9d1a

Browse files
lxdictedrichardlau
authored andcommitted
deps: update to c-ares 1.17.1
PR-URL: #36207 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 39e9cd5 commit 4ae9d1a

17 files changed

+373
-54
lines changed

deps/cares/cares.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
'src/ares__parse_into_addrinfo.c',
7676
'src/ares_parse_aaaa_reply.c',
7777
'src/ares_parse_a_reply.c',
78+
'src/ares_parse_caa_reply.c',
7879
'src/ares_parse_mx_reply.c',
7980
'src/ares_parse_naptr_reply.c',
8081
'src/ares_parse_ns_reply.c',

deps/cares/include/ares_version.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
#define ARES_COPYRIGHT "2004 - 2020 Daniel Stenberg, <daniel@haxx.se>."
77

88
#define ARES_VERSION_MAJOR 1
9-
#define ARES_VERSION_MINOR 16
9+
#define ARES_VERSION_MINOR 17
1010
#define ARES_VERSION_PATCH 1
1111
#define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
1212
(ARES_VERSION_MINOR<<8)|\
1313
(ARES_VERSION_PATCH))
14-
#define ARES_VERSION_STR "1.16.1"
14+
#define ARES_VERSION_STR "1.17.1"
1515

1616
#if (ARES_VERSION >= 0x010700)
1717
# define CARES_HAVE_ARES_LIBRARY_INIT 1

deps/cares/include/nameser.h

+7
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ typedef enum __ns_type {
8888
ns_t_maila = 254, /* Transfer mail agent records. */
8989
ns_t_any = 255, /* Wildcard match. */
9090
ns_t_zxfr = 256, /* BIND-specific, nonstandard. */
91+
ns_t_caa = 257, /* Certification Authority Authorization. */
9192
ns_t_max = 65536
9293
} ns_type;
9394

@@ -204,8 +205,14 @@ typedef enum __ns_rcode {
204205
#define T_AXFR ns_t_axfr
205206
#define T_MAILB ns_t_mailb
206207
#define T_MAILA ns_t_maila
208+
#define T_CAA ns_t_caa
207209
#define T_ANY ns_t_any
208210

209211
#endif /* HAVE_ARPA_NAMESER_COMPAT_H */
210212

213+
/* Android's bionic arpa/nameser_compat.h, nor glibc versions prior to 2.25 have T_OPT defined */
214+
#ifndef T_OPT
215+
# define T_OPT ns_t_opt
216+
#endif
217+
211218
#endif /* ARES_NAMESER_H */

deps/cares/src/ares__readaddrinfo.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ int ares__readaddrinfo(FILE *fp,
163163
continue;
164164
}
165165

166+
/* Zero-out 'addr' struct, as there are members that we may not set, especially
167+
* for ipv6. We don't want garbage data */
168+
memset(&addr, 0, sizeof(addr));
169+
166170
/*
167171
* Convert address string to network address for the requested families.
168172
* Actual address family possible values are AF_INET and AF_INET6 only.
@@ -179,7 +183,7 @@ int ares__readaddrinfo(FILE *fp,
179183
}
180184

181185
node->ai_family = addr.sa.sa_family = AF_INET;
182-
node->ai_addrlen = sizeof(sizeof(addr.sa4));
186+
node->ai_addrlen = sizeof(addr.sa4);
183187
node->ai_addr = ares_malloc(sizeof(addr.sa4));
184188
if (!node->ai_addr)
185189
{
@@ -200,7 +204,7 @@ int ares__readaddrinfo(FILE *fp,
200204
}
201205

202206
node->ai_family = addr.sa.sa_family = AF_INET6;
203-
node->ai_addrlen = sizeof(sizeof(addr.sa6));
207+
node->ai_addrlen = sizeof(addr.sa6);
204208
node->ai_addr = ares_malloc(sizeof(addr.sa6));
205209
if (!node->ai_addr)
206210
{

deps/cares/src/ares__sortaddrinfo.c

+11-10
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ struct addrinfo_sort_elem
8585
#define ARES_IN6_IS_ADDR_6BONE(a) \
8686
(((a)->s6_addr[0] == 0x3f) && ((a)->s6_addr[1] == 0xfe))
8787

88+
8889
static int get_scope(const struct sockaddr *addr)
8990
{
9091
if (addr->sa_family == AF_INET6)
9192
{
92-
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr;
93+
const struct sockaddr_in6 *addr6 = CARES_INADDR_CAST(const struct sockaddr_in6 *, addr);
9394
if (IN6_IS_ADDR_MULTICAST(&addr6->sin6_addr))
9495
{
9596
return ARES_IPV6_ADDR_MC_SCOPE(&addr6->sin6_addr);
@@ -114,7 +115,7 @@ static int get_scope(const struct sockaddr *addr)
114115
}
115116
else if (addr->sa_family == AF_INET)
116117
{
117-
const struct sockaddr_in *addr4 = (const struct sockaddr_in *)addr;
118+
const struct sockaddr_in *addr4 = CARES_INADDR_CAST(const struct sockaddr_in *, addr);
118119
unsigned long int na = ntohl(addr4->sin_addr.s_addr);
119120
if (ARES_IN_LOOPBACK(na) || /* 127.0.0.0/8 */
120121
(na & 0xffff0000) == 0xa9fe0000) /* 169.254.0.0/16 */
@@ -149,7 +150,7 @@ static int get_label(const struct sockaddr *addr)
149150
}
150151
else if (addr->sa_family == AF_INET6)
151152
{
152-
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr;
153+
const struct sockaddr_in6 *addr6 = CARES_INADDR_CAST(const struct sockaddr_in6 *, addr);
153154
if (IN6_IS_ADDR_LOOPBACK(&addr6->sin6_addr))
154155
{
155156
return 0;
@@ -210,7 +211,7 @@ static int get_precedence(const struct sockaddr *addr)
210211
}
211212
else if (addr->sa_family == AF_INET6)
212213
{
213-
const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *)addr;
214+
const struct sockaddr_in6 *addr6 = CARES_INADDR_CAST(const struct sockaddr_in6 *, addr);
214215
if (IN6_IS_ADDR_LOOPBACK(&addr6->sin6_addr))
215216
{
216217
return 50;
@@ -353,10 +354,10 @@ static int rfc6724_compare(const void *ptr1, const void *ptr2)
353354
{
354355
const struct sockaddr_in6 *a1_src = &a1->src_addr.sa6;
355356
const struct sockaddr_in6 *a1_dst =
356-
(const struct sockaddr_in6 *)a1->ai->ai_addr;
357+
CARES_INADDR_CAST(const struct sockaddr_in6 *, a1->ai->ai_addr);
357358
const struct sockaddr_in6 *a2_src = &a2->src_addr.sa6;
358359
const struct sockaddr_in6 *a2_dst =
359-
(const struct sockaddr_in6 *)a2->ai->ai_addr;
360+
CARES_INADDR_CAST(const struct sockaddr_in6 *, a2->ai->ai_addr);
360361
prefixlen1 = common_prefix_len(&a1_src->sin6_addr, &a1_dst->sin6_addr);
361362
prefixlen2 = common_prefix_len(&a2_src->sin6_addr, &a2_dst->sin6_addr);
362363
if (prefixlen1 != prefixlen2)
@@ -384,7 +385,7 @@ static int find_src_addr(ares_channel channel,
384385
const struct sockaddr *addr,
385386
struct sockaddr *src_addr)
386387
{
387-
int sock;
388+
ares_socket_t sock;
388389
int ret;
389390
ares_socklen_t len;
390391

@@ -402,7 +403,7 @@ static int find_src_addr(ares_channel channel,
402403
}
403404

404405
sock = ares__open_socket(channel, addr->sa_family, SOCK_DGRAM, IPPROTO_UDP);
405-
if (sock == -1)
406+
if (sock == ARES_SOCKET_BAD)
406407
{
407408
if (errno == EAFNOSUPPORT)
408409
{
@@ -426,7 +427,7 @@ static int find_src_addr(ares_channel channel,
426427
return 0;
427428
}
428429

429-
if (getsockname(sock, src_addr, &len) == -1)
430+
if (getsockname(sock, src_addr, &len) != 0)
430431
{
431432
ares__close_socket(channel, sock);
432433
return -1;
@@ -491,4 +492,4 @@ int ares__sortaddrinfo(ares_channel channel, struct ares_addrinfo_node *list_sen
491492

492493
ares_free(elems);
493494
return ARES_SUCCESS;
494-
}
495+
}

deps/cares/src/ares_data.c

+18
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ void ares_free_data(void *dataptr)
119119
ares_free(ptr->data.soa_reply.hostmaster);
120120
break;
121121

122+
case ARES_DATATYPE_CAA_REPLY:
123+
124+
if (ptr->data.caa_reply.next)
125+
next_data = ptr->data.caa_reply.next;
126+
if (ptr->data.caa_reply.property)
127+
ares_free(ptr->data.caa_reply.property);
128+
if (ptr->data.caa_reply.value)
129+
ares_free(ptr->data.caa_reply.value);
130+
break;
131+
122132
default:
123133
return;
124134
}
@@ -174,6 +184,14 @@ void *ares_malloc_data(ares_datatype type)
174184
ptr->data.txt_reply.length = 0;
175185
break;
176186

187+
case ARES_DATATYPE_CAA_REPLY:
188+
ptr->data.caa_reply.next = NULL;
189+
ptr->data.caa_reply.plength = 0;
190+
ptr->data.caa_reply.property = NULL;
191+
ptr->data.caa_reply.length = 0;
192+
ptr->data.caa_reply.value = NULL;
193+
break;
194+
177195
case ARES_DATATYPE_ADDR_NODE:
178196
ptr->data.addr_node.next = NULL;
179197
ptr->data.addr_node.family = 0;

deps/cares/src/ares_data.h

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ typedef enum {
3030
ARES_DATATYPE_OPTIONS, /* struct ares_options */
3131
#endif
3232
ARES_DATATYPE_ADDR_PORT_NODE, /* struct ares_addr_port_node - introduced in 1.11.0 */
33+
ARES_DATATYPE_CAA_REPLY, /* struct ares_caa_reply - introduced in 1.17 */
3334
ARES_DATATYPE_LAST /* not used - introduced in 1.7.0 */
3435
} ares_datatype;
3536

@@ -65,6 +66,7 @@ struct ares_data {
6566
struct ares_mx_reply mx_reply;
6667
struct ares_naptr_reply naptr_reply;
6768
struct ares_soa_reply soa_reply;
69+
struct ares_caa_reply caa_reply;
6870
} data;
6971
};
7072

deps/cares/src/ares_getaddrinfo.c

+11
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ static int fake_addrinfo(const char *name,
386386
}
387387
}
388388

389+
node->ai_socktype = hints->ai_socktype;
390+
node->ai_protocol = hints->ai_protocol;
391+
389392
callback(arg, ARES_SUCCESS, 0, ai);
390393
return 1;
391394
}
@@ -406,6 +409,8 @@ static void end_hquery(struct host_query *hquery, int status)
406409
/* Set port into each address (resolved separately). */
407410
while (next)
408411
{
412+
next->ai_socktype = hquery->hints.ai_socktype;
413+
next->ai_protocol = hquery->hints.ai_protocol;
409414
if (next->ai_family == AF_INET)
410415
{
411416
(CARES_INADDR_CAST(struct sockaddr_in *, next->ai_addr))->sin_port = htons(hquery->port);
@@ -754,12 +759,18 @@ static int as_is_first(const struct host_query* hquery)
754759
{
755760
char* p;
756761
int ndots = 0;
762+
size_t nname = strlen(hquery->name);
757763
for (p = hquery->name; *p; p++)
758764
{
759765
if (*p == '.')
760766
{
761767
ndots++;
762768
}
763769
}
770+
if (nname && hquery->name[nname-1] == '.')
771+
{
772+
/* prevent ARES_EBADNAME for valid FQDN, where ndots < channel->ndots */
773+
return 1;
774+
}
764775
return ndots >= hquery->channel->ndots;
765776
}

deps/cares/src/ares_gethostbyaddr.c

-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
208208
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
209209

210210
#elif defined(WATT32)
211-
extern const char *_w32_GetHostsFile (void);
212211
const char *PATH_HOSTS = _w32_GetHostsFile();
213212

214213
if (!PATH_HOSTS)

deps/cares/src/ares_gethostbyname.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static int fake_hostent(const char *name, int family,
258258
struct in_addr in;
259259
struct ares_in6_addr in6;
260260

261-
if (family == AF_INET || family == AF_INET6)
261+
if (family == AF_INET || family == AF_UNSPEC)
262262
{
263263
/* It only looks like an IP address if it's all numbers and dots. */
264264
int numdots = 0, valid = 1;
@@ -276,13 +276,17 @@ static int fake_hostent(const char *name, int family,
276276
/* if we don't have 3 dots, it is illegal
277277
* (although inet_pton doesn't think so).
278278
*/
279-
if (numdots != 3 || !valid)
279+
if (numdots != 3 || !valid) {
280280
result = 0;
281-
else
281+
} else {
282282
result = (ares_inet_pton(AF_INET, name, &in) < 1 ? 0 : 1);
283+
}
283284

284-
if (result)
285-
family = AF_INET;
285+
/*
286+
* Set address family in case of failure,
287+
* as we will try to convert it later afterwards
288+
*/
289+
family = result ? AF_INET : AF_INET6;
286290
}
287291
if (family == AF_INET6)
288292
result = (ares_inet_pton(AF_INET6, name, &in6) < 1 ? 0 : 1);
@@ -383,7 +387,6 @@ static int file_lookup(const char *name, int family, struct hostent **host)
383387
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
384388

385389
#elif defined(WATT32)
386-
extern const char *_w32_GetHostsFile (void);
387390
const char *PATH_HOSTS = _w32_GetHostsFile();
388391

389392
if (!PATH_HOSTS)

deps/cares/src/ares_init.c

+4-16
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,6 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
115115
int status = ARES_SUCCESS;
116116
struct timeval now;
117117

118-
#ifdef CURLDEBUG
119-
const char *env = getenv("CARES_MEMDEBUG");
120-
121-
if (env)
122-
curl_memdebug(env);
123-
env = getenv("CARES_MEMLIMIT");
124-
if (env) {
125-
char *endptr;
126-
long num = strtol(env, &endptr, 10);
127-
if((endptr != env) && (endptr == env + strlen(env)) && (num > 0))
128-
curl_memlimit(num);
129-
}
130-
#endif
131-
132118
if (ares_library_initialized() != ARES_SUCCESS)
133119
return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
134120

@@ -1611,7 +1597,8 @@ static int init_by_resolv_conf(ares_channel channel)
16111597
if (channel->nservers == -1) {
16121598
union res_sockaddr_union addr[MAXNS];
16131599
int nscount = res_getservers(&res, addr, MAXNS);
1614-
for (int i = 0; i < nscount; ++i) {
1600+
int i;
1601+
for (i = 0; i < nscount; ++i) {
16151602
char str[INET6_ADDRSTRLEN];
16161603
int config_status;
16171604
sa_family_t family = addr[i].sin.sin_family;
@@ -1639,8 +1626,9 @@ static int init_by_resolv_conf(ares_channel channel)
16391626
if (!channel->domains) {
16401627
status = ARES_ENOMEM;
16411628
} else {
1629+
int i;
16421630
channel->ndomains = entries;
1643-
for (int i = 0; i < channel->ndomains; ++i) {
1631+
for (i = 0; i < channel->ndomains; ++i) {
16441632
channel->domains[i] = ares_strdup(res.dnsrch[i]);
16451633
if (!channel->domains[i])
16461634
status = ARES_ENOMEM;

0 commit comments

Comments
 (0)