Skip to content

Commit 0766369

Browse files
bnoordhuistargos
authored andcommittedNov 6, 2018
deps: upgrade to c-ares v1.15.0
Our out-of-tree patch from 2b6bb9f ("deps: c-ares float, win ipv6 bad fec0 prefix") should no longer be necessary, c-ares now blacklists such addresses itself. PR-URL: #23854 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent eaea90b commit 0766369

23 files changed

+662
-285
lines changed
 

‎deps/cares/LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# c-ares license
22

3-
Copyright (c) 2007 - 2016, Daniel Stenberg with many contributors, see AUTHORS
3+
Copyright (c) 2007 - 2018, Daniel Stenberg with many contributors, see AUTHORS
44
file.
55

66
Copyright 1998 by the Massachusetts Institute of Technology.

‎deps/cares/cares.gyp

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
'src/ares_strdup.c',
9393
'src/ares_strdup.h',
9494
'src/ares_strerror.c',
95+
'src/ares_strsplit.c',
9596
'src/ares_timeout.c',
9697
'src/ares__timeval.c',
9798
'src/ares_version.c',

‎deps/cares/include/ares.h

+2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ extern "C" {
164164
#define ARES_OPT_ROTATE (1 << 14)
165165
#define ARES_OPT_EDNSPSZ (1 << 15)
166166
#define ARES_OPT_NOROTATE (1 << 16)
167+
#define ARES_OPT_RESOLVCONF (1 << 17)
167168

168169
/* Nameinfo flag values */
169170
#define ARES_NI_NOFQDN (1 << 0)
@@ -270,6 +271,7 @@ struct ares_options {
270271
struct apattern *sortlist;
271272
int nsort;
272273
int ednspsz;
274+
char *resolvconf_path;
273275
};
274276

275277
struct hostent;

‎deps/cares/include/ares_build.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,14 @@
194194
/* Data type definition of ares_ssize_t. */
195195
#ifdef _WIN32
196196
# ifdef _WIN64
197-
typedef __int64 ares_ssize_t;
197+
# define CARES_TYPEOF_ARES_SSIZE_T __int64
198198
# else
199-
typedef long ares_ssize_t;
199+
# define CARES_TYPEOF_ARES_SSIZE_T long
200200
# endif
201201
#else
202-
# ifdef CARES_TYPEOF_ARES_SSIZE_T
203-
typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t;
204-
# else
205-
typedef ssize_t ares_ssize_t;
206-
# endif
202+
# define CARES_TYPEOF_ARES_SSIZE_T ssize_t
207203
#endif
208204

205+
typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t;
206+
209207
#endif /* __CARES_BUILD_H */

‎deps/cares/include/ares_rules.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383

8484
/*
8585
* Verify that the size previously defined and expected for
86-
* ares_socklen_t is actually the the same as the one reported
86+
* ares_socklen_t is actually the same as the one reported
8787
* by sizeof() at compile time.
8888
*/
8989

‎deps/cares/src/RELEASE-NOTES

+34-38
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,43 @@
1-
c-ares version 1.14.0
1+
c-ares version 1.15.0
22

33
Changes:
4-
o android: Introduce new ares_library_init_android() call for Oreo support. [5]
4+
o Add ares_init_options() configurability for path to resolv.conf file [1]
5+
o Ability to exclude building of tools (adig, ahost, acountry) in CMake [3]
6+
o Android: Support for domain search suffix [4]
7+
o Report ARES_ENOTFOUND for .onion domain names as per RFC7686. [13]
58

69
Bug fixes:
7-
8-
o Fix patch for CVE-2017-1000381 to not be overly aggressive. [1]
9-
o win32: Preserve DNS server order returned by Windows when sorting and exclude
10-
DNS servers in legacy subnets. [2] [4]
11-
o win32: Support most recent Visual Studio 2017
12-
o gethostbyaddr should fail with ECANCELLED not ENOTFOUND when ares_cancel
13-
is called. [3]
14-
o win32: Exclude legacy ipv6 subnets [4]
15-
o android: Applications compiled for Oreo can no longer use
16-
__system_property_get and must use Java calls to retrieve DNS servers.
17-
[5] [7]
18-
o win32: Force use of ANSI functions [6]
19-
o CMake minimum version is now 3.1
20-
o ares_gethostbyname.3: fix callback status values [8]
21-
o docs: Document WSAStartup requirement [9]
22-
o Fix a typo in init_by_resolv_conf [10]
23-
o Android JNI code leaks local references in some cases [11]
24-
o Force using the ANSI versions of WinAPI functions [12]
10+
o AIX build fix for trying to include both nameser_compat.h and
11+
onameser_compat.h [2]
12+
o Windows: Improve DNS suffixes extracting from WinNT registry [5]
13+
o Fix modern GCC warnings [6]
14+
o Apply the IPv6 server blacklist to all nameserver sources, not just Windows
15+
[7]
16+
o Fix warnings emitted by MSVC when using -W4 [8]
17+
o Prevent changing name servers while queries are outstanding [9]
18+
o Harden and rationalize c-ares timeout computation [10]
19+
o Distribute ares_android.h [11]
20+
o ares_set_servers_csv() on failure should not leave channel in a bad state
21+
[12]
22+
o Add missing docs to distribution
2523

2624
Thanks go to these friendly people for their efforts and contributions:
27-
28-
AC Thompson, Anna Henningsen, Antonio Tajuelo, Brad House, Brad Spencer,
29-
Christian Ammer, Daniel Stenberg, David Drysdale, David Hotham, Felix Yan,
30-
Gergely Nagy, Gregor Jasny, Jakub Hrozek, John Schember,
31-
Konstantinos Sofokleous, Roman Teterin, Sergey Kolomenkin, Sheel Bedi,
32-
(18 contributors)
25+
@afalin, Andi Schnebinger, Ben Noordhuis, Brad House, Brad Spencer,
26+
David Hotham, @flyingdutchman23, John Schember, Ruslan Baratov,
27+
Sarat Addepalli, Tobias Nießen (11 contributors)
3328

3429
References to bug reports and discussions on issues:
30+
[1] = https://github.com/c-ares/c-ares/issues/220
31+
[2] = https://github.com/c-ares/c-ares/issues/224
32+
[3] = https://github.com/c-ares/c-ares/issues/200
33+
[4] = https://github.com/c-ares/c-ares/issues/207
34+
[5] = https://github.com/c-ares/c-ares/pull/202
35+
[6] = https://github.com/c-ares/c-ares/pull/201
36+
[7] = https://github.com/c-ares/c-ares/pull/193
37+
[8] = https://github.com/c-ares/c-ares/pull/192
38+
[9] = https://github.com/c-ares/c-ares/pull/191
39+
[10] = https://github.com/c-ares/c-ares/pull/187
40+
[11] = https://c-ares.haxx.se/mail/c-ares-archive-2018-04/0000.shtml
41+
[12] = https://c-ares.haxx.se/mail/c-ares-archive-2018-03/0000.shtml
42+
[13] = https://github.com/c-ares/c-ares/issues/196
3543

36-
[1] = https://github.com/c-ares/c-ares/commit/18ea99
37-
[2] = https://github.com/c-ares/c-ares/issues/150
38-
[3] = https://github.com/c-ares/c-ares/pull/138
39-
[4] = https://github.com/c-ares/c-ares/pull/144
40-
[5] = https://github.com/c-ares/c-ares/pull/148
41-
[6] = https://github.com/c-ares/c-ares/pull/142
42-
[7] = https://github.com/c-ares/c-ares/pull/175
43-
[8] = https://c-ares.haxx.se/mail/c-ares-archive-2011-06/0012.shtml
44-
[9] = https://github.com/c-ares/c-ares/pull/180
45-
[10] = https://github.com/c-ares/c-ares/pull/160
46-
[11] = https://github.com/c-ares/c-ares/pull/175
47-
[12] = https://github.com/c-ares/c-ares/pull/142

‎deps/cares/src/ares_android.c

+99
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ static jmethodID android_cm_active_net_mid = NULL;
3030
static jmethodID android_cm_link_props_mid = NULL;
3131
/* LinkProperties.getDnsServers */
3232
static jmethodID android_lp_dns_servers_mid = NULL;
33+
/* LinkProperties.getDomains */
34+
static jmethodID android_lp_domains_mid = NULL;
3335
/* List.size */
3436
static jmethodID android_list_size_mid = NULL;
3537
/* List.get */
@@ -139,6 +141,12 @@ int ares_library_init_android(jobject connectivity_manager)
139141
if (android_lp_dns_servers_mid == NULL)
140142
goto cleanup;
141143

144+
/* getDomains in API 21. */
145+
android_lp_domains_mid = jni_get_method_id(env, obj_cls, "getDomains",
146+
"()Ljava/lang/String;");
147+
if (android_lp_domains_mid == NULL)
148+
goto cleanup;
149+
142150
(*env)->DeleteLocalRef(env, obj_cls);
143151
obj_cls = jni_get_class(env, "java/util/List");
144152
if (obj_cls == NULL)
@@ -173,6 +181,7 @@ int ares_library_init_android(jobject connectivity_manager)
173181
android_cm_active_net_mid = NULL;
174182
android_cm_link_props_mid = NULL;
175183
android_lp_dns_servers_mid = NULL;
184+
android_lp_domains_mid = NULL;
176185
android_list_size_mid = NULL;
177186
android_list_get_mid = NULL;
178187
android_ia_host_addr_mid = NULL;
@@ -213,6 +222,7 @@ void ares_library_cleanup_android(void)
213222
android_cm_active_net_mid = NULL;
214223
android_cm_link_props_mid = NULL;
215224
android_lp_dns_servers_mid = NULL;
225+
android_lp_domains_mid = NULL;
216226
android_list_size_mid = NULL;
217227
android_list_get_mid = NULL;
218228
android_ia_host_addr_mid = NULL;
@@ -341,6 +351,95 @@ char **ares_get_android_server_list(size_t max_servers,
341351
(*android_jvm)->DetachCurrentThread(android_jvm);
342352
return dns_list;
343353
}
354+
355+
char *ares_get_android_search_domains_list(void)
356+
{
357+
JNIEnv *env = NULL;
358+
jobject active_network = NULL;
359+
jobject link_properties = NULL;
360+
jstring domains = NULL;
361+
const char *domain;
362+
int res;
363+
size_t i;
364+
size_t cnt = 0;
365+
char *domain_list = NULL;
366+
int need_detatch = 0;
367+
368+
if (android_jvm == NULL || android_connectivity_manager == NULL)
369+
{
370+
return NULL;
371+
}
372+
373+
if (android_cm_active_net_mid == NULL || android_cm_link_props_mid == NULL ||
374+
android_lp_domains_mid == NULL)
375+
{
376+
return NULL;
377+
}
378+
379+
res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6);
380+
if (res == JNI_EDETACHED)
381+
{
382+
env = NULL;
383+
res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL);
384+
need_detatch = 1;
385+
}
386+
if (res != JNI_OK || env == NULL)
387+
goto done;
388+
389+
/* JNI below is equivalent to this Java code.
390+
import android.content.Context;
391+
import android.net.ConnectivityManager;
392+
import android.net.LinkProperties;
393+
394+
ConnectivityManager cm = (ConnectivityManager)this.getApplicationContext()
395+
.getSystemService(Context.CONNECTIVITY_SERVICE);
396+
Network an = cm.getActiveNetwork();
397+
LinkProperties lp = cm.getLinkProperties(an);
398+
String domains = lp.getDomains();
399+
for (String domain: domains.split(",")) {
400+
String d = domain;
401+
}
402+
403+
Note: The JNI ConnectivityManager object and all method IDs were previously
404+
initialized in ares_library_init_android.
405+
*/
406+
407+
active_network = (*env)->CallObjectMethod(env, android_connectivity_manager,
408+
android_cm_active_net_mid);
409+
if (active_network == NULL)
410+
goto done;
411+
412+
link_properties =
413+
(*env)->CallObjectMethod(env, android_connectivity_manager,
414+
android_cm_link_props_mid, active_network);
415+
if (link_properties == NULL)
416+
goto done;
417+
418+
/* Get the domains. It is a common separated list of domains to search. */
419+
domains = (*env)->CallObjectMethod(env, link_properties,
420+
android_lp_domains_mid);
421+
if (domains == NULL)
422+
goto done;
423+
424+
/* Split on , */
425+
domain = (*env)->GetStringUTFChars(env, domains, 0);
426+
domain_list = ares_strdup(domain);
427+
(*env)->ReleaseStringUTFChars(env, domains, domain);
428+
(*env)->DeleteLocalRef(env, domains);
429+
430+
done:
431+
if ((*env)->ExceptionOccurred(env))
432+
(*env)->ExceptionClear(env);
433+
434+
if (link_properties != NULL)
435+
(*env)->DeleteLocalRef(env, link_properties);
436+
if (active_network != NULL)
437+
(*env)->DeleteLocalRef(env, active_network);
438+
439+
if (need_detatch)
440+
(*android_jvm)->DetachCurrentThread(android_jvm);
441+
return domain_list;
442+
}
344443
#else
345444
/* warning: ISO C forbids an empty translation unit */
346445
typedef int dummy_make_iso_compilers_happy;

‎deps/cares/src/ares_android.h

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#if defined(ANDROID) || defined(__ANDROID__)
2020

2121
char **ares_get_android_server_list(size_t max_servers, size_t *num_servers);
22+
char *ares_get_android_search_domains_list(void);
2223
void ares_library_cleanup_android(void);
2324

2425
#endif

‎deps/cares/src/ares_create_query.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ int ares_create_query(const char *name, int dnsclass, int type,
9494
size_t buflen;
9595
unsigned char *buf;
9696

97+
/* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */
98+
if (ares__is_onion_domain(name))
99+
return ARES_ENOTFOUND;
100+
97101
/* Set our results early, in case we bail out early with an error. */
98102
*buflenp = 0;
99103
*bufp = NULL;
@@ -188,7 +192,7 @@ int ares_create_query(const char *name, int dnsclass, int type,
188192
* specified in RFC 1035 ("To simplify implementations, the total length of
189193
* a domain name (i.e., label octets and label length octets) is restricted
190194
* to 255 octets or less."). */
191-
if (buflen > (MAXCDNAME + HFIXEDSZ + QFIXEDSZ +
195+
if (buflen > (size_t)(MAXCDNAME + HFIXEDSZ + QFIXEDSZ +
192196
(max_udp_size ? EDNSFIXEDSZ : 0))) {
193197
ares_free (buf);
194198
return ARES_EBADNAME;

‎deps/cares/src/ares_destroy.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ void ares_destroy_options(struct ares_options *options)
3636
ares_free(options->sortlist);
3737
if(options->lookups)
3838
ares_free(options->lookups);
39+
if(options->resolvconf_path)
40+
ares_free(options->resolvconf_path);
3941
}
4042

4143
void ares_destroy(ares_channel channel)
@@ -44,7 +46,7 @@ void ares_destroy(ares_channel channel)
4446
struct query *query;
4547
struct list_node* list_head;
4648
struct list_node* list_node;
47-
49+
4850
if (!channel)
4951
return;
5052

@@ -85,6 +87,9 @@ void ares_destroy(ares_channel channel)
8587
if (channel->lookups)
8688
ares_free(channel->lookups);
8789

90+
if (channel->resolvconf_path)
91+
ares_free(channel->resolvconf_path);
92+
8893
ares_free(channel);
8994
}
9095

‎deps/cares/src/ares_gethostbyname.c

+11
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ void ares_gethostbyname(ares_channel channel, const char *name, int family,
9595
return;
9696
}
9797

98+
/* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */
99+
if (ares__is_onion_domain(name))
100+
{
101+
callback(arg, ARES_ENOTFOUND, 0, NULL);
102+
return;
103+
}
104+
98105
if (fake_hostent(name, family, callback, arg))
99106
return;
100107

@@ -339,6 +346,10 @@ static int file_lookup(const char *name, int family, struct hostent **host)
339346
int status;
340347
int error;
341348

349+
/* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */
350+
if (ares__is_onion_domain(name))
351+
return ARES_ENOTFOUND;
352+
342353
#ifdef WIN32
343354
char PATH_HOSTS[MAX_PATH];
344355
win_platform platform;

‎deps/cares/src/ares_getnameinfo.c

+11
Original file line numberDiff line numberDiff line change
@@ -440,3 +440,14 @@ STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2)
440440
}
441441
return (char *)c1_begin;
442442
}
443+
444+
int ares__is_onion_domain(const char *name)
445+
{
446+
if (ares_striendstr(name, ".onion"))
447+
return 1;
448+
449+
if (ares_striendstr(name, ".onion."))
450+
return 1;
451+
452+
return 0;
453+
}

0 commit comments

Comments
 (0)