Skip to content

Commit 18b18c7

Browse files
committed
Update contrib/libs/c-ares to 1.34.3
commit_hash:a4dc6127c1976aed745669af6ede1483b05f9686
1 parent 9632e4f commit 18b18c7

File tree

9 files changed

+138
-30
lines changed

9 files changed

+138
-30
lines changed

contrib/libs/c-ares/.yandex_meta/override.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
pkgs: attrs: with pkgs; with attrs; rec {
2-
version = "1.34.2";
2+
version = "1.34.3";
33

44
src = fetchFromGitHub {
55
owner = "c-ares";
66
repo = "c-ares";
77
rev= "v${version}";
8-
hash = "sha256-KGNOc3l+bWifWFnBOLtL0ASJTuYayBOAE6g6gNsl5xk=";
8+
hash = "sha256-vCVS0kr/l6iRVWRnRM+J8aWheDEqEVVekjF8f4Naj/0=";
99
};
1010

1111
patches = [];

contrib/libs/c-ares/RELEASE-NOTES.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
## c-ares version 1.34.3 - November 9 2024
2+
3+
This is a bugfix release.
4+
5+
Changes:
6+
* Build the release package in an automated way so we can provide
7+
provenance as per [SLSA3](https://slsa.dev/).
8+
[PR #906](https://github.com/c-ares/c-ares/pull/906)
9+
10+
Bugfixes:
11+
* Some upstream servers are non-compliant with EDNS options, resend queries
12+
without EDNS. [Issue #911](https://github.com/c-ares/c-ares/issues/911)
13+
* Android: <=7 needs sys/system_properties.h
14+
[a70637c](https://github.com/c-ares/c-ares/commit/a70637c)
15+
* Android: CMake needs `-D_GNU_SOURCE` and others.
16+
[PR #915](https://github.com/c-ares/c-ares/pull/914)
17+
* TSAN warns on missing lock, but lock isn't actually necessary.
18+
[PR #915](https://github.com/c-ares/c-ares/pull/915)
19+
* `ares_getaddrinfo()` for `AF_UNSPEC` should retry IPv4 if only IPv6 is
20+
received. [765d558](https://github.com/c-ares/c-ares/commit/765d558)
21+
* `ares_send()` shouldn't return `ARES_EBADRESP`, its `ARES_EBADQUERY`.
22+
[91519e7](https://github.com/c-ares/c-ares/commit/91519e7)
23+
* Fix typos in man pages. [PR #905](https://github.com/c-ares/c-ares/pull/905)
24+
25+
Thanks go to these friendly people for their efforts and contributions for this
26+
release:
27+
28+
* Brad House (@bradh352)
29+
* Jiwoo Park (@jimmy-park)
30+
31+
132
## c-ares version 1.34.2 - October 15 2024
233

334
This release contains a fix for downstream packages detecting the c-ares

contrib/libs/c-ares/RELEASE-PROCEDURE.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ in the source code repo
1717
not a commit which may be shared across this branch and `main`. Create the
1818
branch like:
1919
```
20-
BRANCH=1.32
20+
BRANCH=1.35
2121
git pull && \
2222
git checkout main && \
2323
git checkout -b v${BRANCH} main && \
@@ -29,32 +29,27 @@ git push -u origin v${BRANCH}
2929
Major version number, `Y` is the minor version number, and `Z` is the release.
3030
This tag needs to be created from the release branch, for example:
3131
```
32-
BRANCH=1.32
33-
RELEASE=1.32.0
32+
BRANCH=1.35
33+
RELEASE=1.35.0
3434
git checkout v${BRANCH} && \
3535
git pull && \
3636
git tag -s v${RELEASE} -m 'c-ares release v${RELEASE}' v${BRANCH} && \
3737
git push origin --tags
3838
```
39-
- Create the release tarball using `make dist`, it is best to check out the
40-
specific tag fresh and build from that:
39+
- When a tag is created, it will spawn off a github action to generate a new
40+
draft release based on this workflow: [package.yml](https://github.com/c-ares/c-ares/blob/main/.github/workflows/package.yml).
41+
Wait for this workflow to complete then fetch the generated source tarball:
4142
```
42-
RELEASE=1.32.0
43-
git clone --depth 1 --branch v${RELEASE} https://github.com/c-ares/c-ares c-ares-${RELEASE} && \
44-
cd c-ares-${RELEASE} && \
45-
autoreconf -fi && \
46-
./configure && \
47-
make && \
48-
make dist VERSION=${RELEASE}
43+
wget https://github.com/c-ares/c-ares/releases/download/v${RELEASE}/c-ares-${RELEASE}.tar.gz
4944
```
5045
- GPG sign the release with a detached signature. Valid signing keys are currently:
5146
- Daniel Stenberg <daniel@haxx.se> - 27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2
5247
- Brad House <brad@brad-house.com> - DA7D64E4C82C6294CB73A20E22E3D13B5411B7CA
5348
```
5449
gpg -ab c-ares-${RELEASE}.tar.gz
5550
```
56-
- Create a new release on GitHub using the `RELEASE-NOTES.md` as the body.
57-
Upload the generated tarball and signature as an artifact.
51+
- Upload the generated `c-ares-${RELEASE}.tar.gz.asc` signature as a release
52+
asset, then unmark the release as being a draft.
5853

5954
in the c-ares-www repo
6055
----------------------

contrib/libs/c-ares/include/ares_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
#define ARES_VERSION_MAJOR 1
3434
#define ARES_VERSION_MINOR 34
35-
#define ARES_VERSION_PATCH 2
36-
#define ARES_VERSION_STR "1.34.2"
35+
#define ARES_VERSION_PATCH 3
36+
#define ARES_VERSION_STR "1.34.3"
3737

3838
/* NOTE: We cannot make the version string a C preprocessor stringify operation
3939
* due to assumptions made by integrators that aren't properly using

contrib/libs/c-ares/src/lib/ares_getaddrinfo.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,18 @@ static void terminate_retries(const struct host_query *hquery,
481481
query->no_retries = ARES_TRUE;
482482
}
483483

484+
static ares_bool_t ai_has_ipv4(struct ares_addrinfo *ai)
485+
{
486+
struct ares_addrinfo_node *node;
487+
488+
for (node = ai->nodes; node != NULL; node = node->ai_next) {
489+
if (node->ai_family == AF_INET) {
490+
return ARES_TRUE;
491+
}
492+
}
493+
return ARES_FALSE;
494+
}
495+
484496
static void host_callback(void *arg, ares_status_t status, size_t timeouts,
485497
const ares_dns_record_t *dnsrec)
486498
{
@@ -496,7 +508,27 @@ static void host_callback(void *arg, ares_status_t status, size_t timeouts,
496508
addinfostatus =
497509
ares_parse_into_addrinfo(dnsrec, ARES_TRUE, hquery->port, hquery->ai);
498510
}
499-
if (addinfostatus == ARES_SUCCESS) {
511+
512+
/* We sent out ipv4 and ipv6 requests simultaneously. If we got a
513+
* successful ipv4 response, we want to go ahead and tell the ipv6 request
514+
* that if it fails or times out to not try again since we have the data
515+
* we need.
516+
*
517+
* Our initial implementation of this would terminate retries if we got any
518+
* successful response (ipv4 _or_ ipv6). But we did get some user-reported
519+
* issues with this that had bad system configs and odd behavior:
520+
* https://github.com/alpinelinux/docker-alpine/issues/366
521+
*
522+
* Essentially the ipv6 query succeeded but the ipv4 query failed or timed
523+
* out, and so we only returned the ipv6 address, but the host couldn't
524+
* use ipv6. If we continued to allow ipv4 retries it would have found a
525+
* server that worked and returned both address classes (this is clearly
526+
* unexpected behavior).
527+
*
528+
* At some point down the road if ipv6 actually becomes required and
529+
* reliable we can drop this ipv4 check.
530+
*/
531+
if (addinfostatus == ARES_SUCCESS && ai_has_ipv4(hquery->ai)) {
500532
terminate_retries(hquery, ares_dns_record_get_id(dnsrec));
501533
}
502534
}

contrib/libs/c-ares/src/lib/ares_process.c

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,51 @@ static ares_status_t rewrite_without_edns(ares_query_t *query)
650650
return status;
651651
}
652652

653+
static ares_bool_t issue_might_be_edns(const ares_dns_record_t *req,
654+
const ares_dns_record_t *rsp)
655+
{
656+
const ares_dns_rr_t *rr;
657+
658+
/* If we use EDNS and server answers with FORMERR without an OPT RR, the
659+
* protocol extension is not understood by the responder. We must retry the
660+
* query without EDNS enabled. */
661+
if (ares_dns_record_get_rcode(rsp) != ARES_RCODE_FORMERR) {
662+
return ARES_FALSE;
663+
}
664+
665+
rr = ares_dns_get_opt_rr_const(req);
666+
if (rr == NULL) {
667+
/* We didn't send EDNS */
668+
return ARES_FALSE;
669+
}
670+
671+
if (ares_dns_get_opt_rr_const(rsp) == NULL) {
672+
/* Spec says EDNS won't be echo'd back on non-supporting servers, so
673+
* retry without EDNS */
674+
return ARES_TRUE;
675+
}
676+
677+
/* As per issue #911 some non-compliant servers that do indeed support EDNS
678+
* but don't support unrecognized option codes exist. At this point we
679+
* expect them to have also returned an EDNS opt record, but we may remove
680+
* that check in the future. Lets detect this situation if we're sending
681+
* option codes */
682+
if (ares_dns_rr_get_opt_cnt(rr, ARES_RR_OPT_OPTIONS) == 0) {
683+
/* We didn't send any option codes */
684+
return ARES_FALSE;
685+
}
686+
687+
if (ares_dns_get_opt_rr_const(rsp) != NULL) {
688+
/* At this time we're requiring the server to respond with EDNS opt
689+
* records since that's what has been observed in the field. We might
690+
* find in the future we have to remove this, who knows. Lets go
691+
* ahead and force a retry without EDNS*/
692+
return ARES_TRUE;
693+
}
694+
695+
return ARES_FALSE;
696+
}
697+
653698
/* Handle an answer from a server. This must NEVER cleanup the
654699
* server connection! Return something other than ARES_SUCCESS to cause
655700
* the connection to be terminated after this call. */
@@ -713,12 +758,10 @@ static ares_status_t process_answer(ares_channel_t *channel,
713758
ares_llist_node_destroy(query->node_queries_to_conn);
714759
query->node_queries_to_conn = NULL;
715760

716-
/* If we use EDNS and server answers with FORMERR without an OPT RR, the
717-
* protocol extension is not understood by the responder. We must retry the
718-
* query without EDNS enabled. */
719-
if (ares_dns_record_get_rcode(rdnsrec) == ARES_RCODE_FORMERR &&
720-
ares_dns_get_opt_rr_const(query->query) != NULL &&
721-
ares_dns_get_opt_rr_const(rdnsrec) == NULL) {
761+
/* There are old servers that don't understand EDNS at all, then some servers
762+
* that have non-compliant implementations. Lets try to detect this sort
763+
* of thing. */
764+
if (issue_might_be_edns(query->query, rdnsrec)) {
722765
status = rewrite_without_edns(query);
723766
if (status != ARES_SUCCESS) {
724767
end_query(channel, server, query, status, NULL);

contrib/libs/c-ares/src/lib/ares_send.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ ares_status_t ares_send_nolock(ares_channel_t *channel, ares_server_t *server,
153153
/* Duplicate Query */
154154
status = ares_dns_record_duplicate_ex(&query->query, dnsrec);
155155
if (status != ARES_SUCCESS) {
156+
/* Sometimes we might get a EBADRESP response from duplicate due to
157+
* the way it works (write and parse), rewrite it to EBADQUERY. */
158+
if (status == ARES_EBADRESP) {
159+
status = ARES_EBADQUERY;
160+
}
156161
ares_free(query);
157162
callback(arg, status, 0, NULL);
158163
return status;

contrib/libs/c-ares/src/lib/event/ares_event_thread.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,16 @@ static void *ares_event_thread(void *arg)
354354
ares_process_pending_write(e->channel);
355355
}
356356

357+
/* Relock before we loop again */
358+
ares_thread_mutex_lock(e->mutex);
359+
357360
/* Each iteration should do timeout processing and any other cleanup
358361
* that may not have been performed */
359362
if (e->isup) {
363+
ares_thread_mutex_unlock(e->mutex);
360364
ares_process_fds(e->channel, NULL, 0, ARES_PROCESS_FLAG_NONE);
365+
ares_thread_mutex_lock(e->mutex);
361366
}
362-
363-
/* Relock before we loop again */
364-
ares_thread_mutex_lock(e->mutex);
365367
}
366368

367369
/* Lets cleanup while we're in the thread itself */

contrib/libs/c-ares/ya.make

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ LICENSE(
1212

1313
LICENSE_TEXTS(.yandex_meta/licenses.list.txt)
1414

15-
VERSION(1.34.2)
15+
VERSION(1.34.3)
1616

17-
ORIGINAL_SOURCE(https://github.com/c-ares/c-ares/archive/v1.34.2.tar.gz)
17+
ORIGINAL_SOURCE(https://github.com/c-ares/c-ares/archive/v1.34.3.tar.gz)
1818

1919
PEERDIR(
2020
contrib/libs/libc_compat

0 commit comments

Comments
 (0)