main/c-ares: upgrade to 1.26.0

This commit is contained in:
Celeste 2024-01-27 13:30:27 +00:00 committed by J0WI
parent 2702c2fc84
commit d8d67e234c
2 changed files with 4 additions and 259 deletions

View File

@ -1,17 +1,15 @@
# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=c-ares
pkgver=1.25.0
pkgrel=1
pkgver=1.26.0
pkgrel=0
pkgdesc="Asynchronous DNS/names resolver library"
url="https://c-ares.org/"
arch="all"
license="MIT"
makedepends="gtest-dev"
subpackages="$pkgname-doc $pkgname-static $pkgname-dev $pkgname-utils::noarch"
source="https://c-ares.haxx.se/download/c-ares-$pkgver.tar.gz
no-dns-sanitycheck.patch
"
source="https://c-ares.haxx.se/download/c-ares-$pkgver.tar.gz"
# secfixes:
# 1.17.2-r0:
@ -44,6 +42,5 @@ utils() {
}
sha512sums="
f73ffc45c17f1e952ea5fae8a1d9e1508427f21c821ff470ff0b728cc4a1e21d1274f95d9192c22f704bc7e0f58a633608cfdc1704dfe8950902fdfc3dfa2e1c c-ares-1.25.0.tar.gz
dcd429263ee82096de26f77535cd55f857c7430b50c7dc59f0440437ca222e9795005572f7f9c65eaa68d18126400811ad6d513eee9c85c2532c054386d784f9 no-dns-sanitycheck.patch
81657b8b9840a565b04ecf87ef8f0fc3192a9594808e47aed5e5bbebf2b5f0066b0cd5fae70f0fe70b68d428b4cc75fba22d2ae7683c6d0f87979c414c072af1 c-ares-1.26.0.tar.gz
"

View File

@ -1,252 +0,0 @@
From 3d5da765ce2e780d999f56607b3c5ff156485155 Mon Sep 17 00:00:00 2001
From: Brad House <brad@brad-house.com>
Date: Fri, 12 Jan 2024 08:32:50 -0500
Subject: [PATCH 1/3] remove bad sanity check
---
src/lib/ares__parse_into_addrinfo.c | 18 +++++++++++-------
src/lib/ares_parse_ptr_reply.c | 26 ++++++++++++++------------
2 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/src/lib/ares__parse_into_addrinfo.c b/src/lib/ares__parse_into_addrinfo.c
index 308cc2145..a5ce0c594 100644
--- a/src/lib/ares__parse_into_addrinfo.c
+++ b/src/lib/ares__parse_into_addrinfo.c
@@ -81,7 +81,6 @@ ares_status_t ares__parse_into_addrinfo(const unsigned char *abuf, size_t alen,
}
for (i = 0; i < ancount; i++) {
- const char *rname = NULL;
ares_dns_rec_type_t rtype;
const ares_dns_rr_t *rr =
ares_dns_record_rr_get(dnsrec, ARES_SECTION_ANSWER, i);
@@ -91,13 +90,18 @@ ares_status_t ares__parse_into_addrinfo(const unsigned char *abuf, size_t alen,
}
rtype = ares_dns_rr_get_type(rr);
- rname = ares_dns_rr_get_name(rr);
- /* Old code did this hostname sanity check */
- if ((rtype == ARES_REC_TYPE_A || rtype == ARES_REC_TYPE_AAAA) &&
- strcasecmp(rname, hostname) != 0) {
- continue;
- }
+ /* Issue #683
+ * Old code did this hostname sanity check, however it appears this is
+ * flawed logic. Other resolvers don't do this sanity check. Leaving
+ * this code commented out for future reference.
+ *
+ * rname = ares_dns_rr_get_name(rr);
+ * if ((rtype == ARES_REC_TYPE_A || rtype == ARES_REC_TYPE_AAAA) &&
+ * strcasecmp(rname, hostname) != 0) {
+ * continue;
+ * }
+ */
if (rtype == ARES_REC_TYPE_CNAME) {
struct ares_addrinfo_cname *cname;
diff --git a/src/lib/ares_parse_ptr_reply.c b/src/lib/ares_parse_ptr_reply.c
index ffe797f3d..d8a29f272 100644
--- a/src/lib/ares_parse_ptr_reply.c
+++ b/src/lib/ares_parse_ptr_reply.c
@@ -113,7 +113,6 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen_int,
/* Cycle through answers */
for (i = 0; i < ancount; i++) {
- const char *rname = NULL;
const ares_dns_rr_t *rr =
ares_dns_record_rr_get(dnsrec, ARES_SECTION_ANSWER, i);
@@ -141,17 +140,20 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen_int,
continue;
}
- /* Old code compared the name in the rr to the ptrname, so we'll do that
- * check here, but I'm not sure its necessary */
- rname = ares_dns_rr_get_name(rr);
- if (rname == NULL) {
- /* Shouldn't be possible */
- status = ARES_EBADRESP;
- goto done;
- }
- if (strcasecmp(ptrname, rname) != 0) {
- continue;
- }
+ /* Issue #683
+ * Old code compared the name in the rr to the ptrname, but I think this
+ * is wrong since it was proven wrong for A & AAAA records. Leaving
+ * this code commented out for future reference
+ *
+ * rname = ares_dns_rr_get_name(rr);
+ * if (rname == NULL) {
+ * status = ARES_EBADRESP;
+ * goto done;
+ * }
+ * if (strcasecmp(ptrname, rname) != 0) {
+ * continue;
+ * }
+ */
/* Save most recent PTR record as the hostname */
hostname = ares_dns_rr_get_str(rr, ARES_RR_PTR_DNAME);
From 647cf114a3065e4dd74f37cc3cbc83a7456838d8 Mon Sep 17 00:00:00 2001
From: Brad House <brad@brad-house.com>
Date: Fri, 12 Jan 2024 08:50:41 -0500
Subject: [PATCH 2/3] fix tests
---
test/ares-test-parse-a.cc | 12 +++++++++---
test/ares-test-parse-aaaa.cc | 12 +++++++++---
test/ares-test-parse-ptr.cc | 13 ++++++++++---
3 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/test/ares-test-parse-a.cc b/test/ares-test-parse-a.cc
index 9d992c712..53bf7b508 100644
--- a/test/ares-test-parse-a.cc
+++ b/test/ares-test-parse-a.cc
@@ -312,13 +312,18 @@ TEST_F(LibraryTest, ParseAReplyErrors) {
EXPECT_EQ(nullptr, host);
pkt.add_question(new DNSQuestion("example.com", T_A));
- // Question != answer
+ // Question != answer, this is ok as of Issue #683
pkt.questions_.clear();
pkt.add_question(new DNSQuestion("Axample.com", T_A));
data = pkt.data();
- EXPECT_EQ(ARES_ENODATA, ares_parse_a_reply(data.data(), (int)data.size(),
+ EXPECT_EQ(ARES_SUCCESS, ares_parse_a_reply(data.data(), (int)data.size(),
&host, info, &count));
- EXPECT_EQ(nullptr, host);
+ ASSERT_NE(nullptr, host);
+ std::stringstream ss;
+ ss << HostEnt(host);
+ EXPECT_EQ("{'Axample.com' aliases=[] addrs=[2.3.4.5]}", ss.str());
+
+
pkt.questions_.clear();
pkt.add_question(new DNSQuestion("example.com", T_A));
@@ -341,6 +346,7 @@ TEST_F(LibraryTest, ParseAReplyErrors) {
#endif
// Two questions
+ host = nullptr;
pkt.add_question(new DNSQuestion("example.com", T_A));
data = pkt.data();
EXPECT_EQ(ARES_EBADRESP, ares_parse_a_reply(data.data(), (int)data.size(),
diff --git a/test/ares-test-parse-aaaa.cc b/test/ares-test-parse-aaaa.cc
index 2cb867212..d4c03f14f 100644
--- a/test/ares-test-parse-aaaa.cc
+++ b/test/ares-test-parse-aaaa.cc
@@ -139,13 +139,19 @@ TEST_F(LibraryTest, ParseAaaaReplyErrors) {
EXPECT_EQ(nullptr, host);
pkt.add_question(new DNSQuestion("example.com", T_AAAA));
- // Question != answer
+ // Question != answer, this is ok as of Issue #683
pkt.questions_.clear();
pkt.add_question(new DNSQuestion("Axample.com", T_AAAA));
data = pkt.data();
- EXPECT_EQ(ARES_ENODATA, ares_parse_aaaa_reply(data.data(), (int)data.size(),
+ EXPECT_EQ(ARES_SUCCESS, ares_parse_aaaa_reply(data.data(), (int)data.size(),
&host, info, &count));
- EXPECT_EQ(nullptr, host);
+ ASSERT_NE(nullptr, host);
+ std::stringstream ss;
+ ss << HostEnt(host);
+ EXPECT_EQ("{'Axample.com' aliases=[] addrs=[0101:0101:0202:0202:0303:0303:0404:0404]}", ss.str());
+
+
+ host = nullptr;
pkt.questions_.clear();
pkt.add_question(new DNSQuestion("example.com", T_AAAA));
diff --git a/test/ares-test-parse-ptr.cc b/test/ares-test-parse-ptr.cc
index af524510c..7da51c297 100644
--- a/test/ares-test-parse-ptr.cc
+++ b/test/ares-test-parse-ptr.cc
@@ -163,13 +163,20 @@ TEST_F(LibraryTest, ParsePtrReplyErrors) {
addrv4, sizeof(addrv4), AF_INET, &host));
pkt.add_question(new DNSQuestion("64.48.32.16.in-addr.arpa", T_PTR));
- // Question != answer
+ // Question != answer, ok after #683
+ host = nullptr;
pkt.questions_.clear();
pkt.add_question(new DNSQuestion("99.48.32.16.in-addr.arpa", T_PTR));
data = pkt.data();
- EXPECT_EQ(ARES_ENODATA, ares_parse_ptr_reply(data.data(), (int)data.size(),
+ EXPECT_EQ(ARES_SUCCESS, ares_parse_ptr_reply(data.data(), (int)data.size(),
addrv4, sizeof(addrv4), AF_INET, &host));
- EXPECT_EQ(nullptr, host);
+ ASSERT_NE(nullptr, host);
+ std::stringstream ss;
+ ss << HostEnt(host);
+ EXPECT_EQ("{'other.com' aliases=[other.com] addrs=[16.32.48.64]}", ss.str());
+
+
+ host = nullptr;
pkt.questions_.clear();
pkt.add_question(new DNSQuestion("64.48.32.16.in-addr.arpa", T_PTR));
From 538af8cd0019da924d0abdb79eb8444d3d15400c Mon Sep 17 00:00:00 2001
From: Brad House <brad@brad-house.com>
Date: Fri, 12 Jan 2024 09:18:59 -0500
Subject: [PATCH 3/3] fix memory leak in tests
---
test/ares-test-parse-a.cc | 4 ++--
test/ares-test-parse-aaaa.cc | 2 +-
test/ares-test-parse-ptr.cc | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/test/ares-test-parse-a.cc b/test/ares-test-parse-a.cc
index 53bf7b508..58b9e19e6 100644
--- a/test/ares-test-parse-a.cc
+++ b/test/ares-test-parse-a.cc
@@ -322,7 +322,8 @@ TEST_F(LibraryTest, ParseAReplyErrors) {
std::stringstream ss;
ss << HostEnt(host);
EXPECT_EQ("{'Axample.com' aliases=[] addrs=[2.3.4.5]}", ss.str());
-
+ ares_free_hostent(host);
+ host = nullptr;
pkt.questions_.clear();
pkt.add_question(new DNSQuestion("example.com", T_A));
@@ -346,7 +347,6 @@ TEST_F(LibraryTest, ParseAReplyErrors) {
#endif
// Two questions
- host = nullptr;
pkt.add_question(new DNSQuestion("example.com", T_A));
data = pkt.data();
EXPECT_EQ(ARES_EBADRESP, ares_parse_a_reply(data.data(), (int)data.size(),
diff --git a/test/ares-test-parse-aaaa.cc b/test/ares-test-parse-aaaa.cc
index d4c03f14f..6b79675e3 100644
--- a/test/ares-test-parse-aaaa.cc
+++ b/test/ares-test-parse-aaaa.cc
@@ -149,7 +149,7 @@ TEST_F(LibraryTest, ParseAaaaReplyErrors) {
std::stringstream ss;
ss << HostEnt(host);
EXPECT_EQ("{'Axample.com' aliases=[] addrs=[0101:0101:0202:0202:0303:0303:0404:0404]}", ss.str());
-
+ ares_free_hostent(host);
host = nullptr;
pkt.questions_.clear();
diff --git a/test/ares-test-parse-ptr.cc b/test/ares-test-parse-ptr.cc
index 7da51c297..bd413e8f7 100644
--- a/test/ares-test-parse-ptr.cc
+++ b/test/ares-test-parse-ptr.cc
@@ -174,7 +174,7 @@ TEST_F(LibraryTest, ParsePtrReplyErrors) {
std::stringstream ss;
ss << HostEnt(host);
EXPECT_EQ("{'other.com' aliases=[other.com] addrs=[16.32.48.64]}", ss.str());
-
+ ares_free_hostent(host);
host = nullptr;
pkt.questions_.clear();