[c-ares] Apply a couple of patches from upstream 1.4 branch
Jakub Hrozek
jhrozek at fedoraproject.org
Wed Aug 25 08:28:51 UTC 2010
commit 2d340cecb0d37da9d7e87598b535f3dbc713aebf
Author: Jakub Hrozek <jhrozek at redhat.com>
Date: Wed Aug 25 10:21:27 2010 +0200
Apply a couple of patches from upstream 1.4 branch
...-break-that-caused-get_ares_servers-to-fa.patch | 28 +++++++
...ix-aliasing-warning-in-gcc-4.4.4-at-least.patch | 86 ++++++++++++++++++++
0001-fix-memory-leak-in-ares_getnameinfo.patch | 32 +++++++
c-ares.spec | 10 ++-
4 files changed, 155 insertions(+), 1 deletions(-)
---
diff --git a/0001-Add-missing-break-that-caused-get_ares_servers-to-fa.patch b/0001-Add-missing-break-that-caused-get_ares_servers-to-fa.patch
new file mode 100644
index 0000000..964757d
--- /dev/null
+++ b/0001-Add-missing-break-that-caused-get_ares_servers-to-fa.patch
@@ -0,0 +1,28 @@
+From 293cd3170019015b6ce40f9fa5efc45bd89dad1a Mon Sep 17 00:00:00 2001
+From: Ben Greear <greearb at candelatech.com>
+Date: Tue, 24 Aug 2010 16:48:47 -0700
+Subject: [PATCH] Add missing break that caused get_ares_servers to fail.
+
+Reported-by: Ning Dong <flintning at 163.com>
+Signed-off-by: Ben Greear <greearb at candelatech.com>
+---
+ ares_data.c | 3 ++-
+ 1 files changed, 2 insertions(+), 1 deletions(-)
+
+diff --git a/ares_data.c b/ares_data.c
+index 6b6fae8..a2477be 100644
+--- a/ares_data.c
++++ b/ares_data.c
+@@ -145,7 +145,8 @@ void *ares_malloc_data(ares_datatype type)
+ ptr->data.addr_node.next = NULL;
+ ptr->data.addr_node.family = 0;
+ memset(&ptr->data.addr_node.addrV6, 0,
+- sizeof(ptr->data.addr_node.addrV6));
++ sizeof(ptr->data.addr_node.addrV6));
++ break;
+
+ default:
+ free(ptr);
+--
+1.7.2.1
+
diff --git a/0001-Fix-aliasing-warning-in-gcc-4.4.4-at-least.patch b/0001-Fix-aliasing-warning-in-gcc-4.4.4-at-least.patch
new file mode 100644
index 0000000..fd9a742
--- /dev/null
+++ b/0001-Fix-aliasing-warning-in-gcc-4.4.4-at-least.patch
@@ -0,0 +1,86 @@
+From 07bc7ea79509bcc9ef6e09151e81766ed00d3392 Mon Sep 17 00:00:00 2001
+From: Ben Greear <greearb at candelatech.com>
+Date: Sat, 31 Jul 2010 07:10:23 -0700
+Subject: [PATCH] Fix aliasing warning in gcc 4.4.4 (at least).
+
+Should be no functional change, though the code gets a bit
+ugglier.
+
+Signed-off-by: Ben Greear <greearb at candelatech.com>
+---
+ ares_process.c | 23 ++++++++++++++++++-----
+ 1 files changed, 18 insertions(+), 5 deletions(-)
+
+diff --git a/ares_process.c b/ares_process.c
+index c3d7fa4..320dd5e 100644
+--- a/ares_process.c
++++ b/ares_process.c
+@@ -434,11 +434,15 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds,
+ unsigned char buf[PACKETSZ + 1];
+ #ifdef HAVE_RECVFROM
+ ares_socklen_t fromlen;
++#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
++ struct sockaddr_storage from;
++#else
+ union {
+ struct sockaddr_in sa4;
+ struct sockaddr_in6 sa6;
+ } from;
+ #endif
++#endif
+
+ if(!read_fds && (read_fd == ARES_SOCKET_BAD))
+ /* no possible action */
+@@ -473,10 +477,7 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds,
+ * packets as we can. */
+ do {
+ #ifdef HAVE_RECVFROM
+- if (server->addr.family == AF_INET)
+- fromlen = sizeof(from.sa4);
+- else
+- fromlen = sizeof(from.sa6);
++ fromlen = sizeof(from); /* doesn't matter if it's larger than needed */
+ count = (ssize_t)recvfrom(server->udp_socket, (void *)buf, sizeof(buf),
+ 0, (struct sockaddr *)&from, &fromlen);
+ #else
+@@ -487,7 +488,15 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds,
+ else if (count <= 0)
+ handle_error(channel, i, now);
+ #ifdef HAVE_RECVFROM
+- else if (!same_address((struct sockaddr *)&from, &server->addr))
++#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
++ /* This family hack works around compiler warnings about
++ * aliases.
++ */
++ else if (!((from.ss_family == server->addr.family) &&
++ same_address((struct sockaddr *)&from, &server->addr)))
++#else
++ else if (!same_address((struct sockaddr *)&from, &server->addr)))
++#endif
+ /* The address the response comes from does not match
+ * the address we sent the request to. Someone may be
+ * attempting to perform a cache poisoning attack. */
+@@ -1177,8 +1186,10 @@ static int same_address(struct sockaddr *sa, struct ares_addr *aa)
+ void *addr1;
+ void *addr2;
+
++#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
+ if (sa->sa_family == aa->family)
+ {
++#endif
+ switch (aa->family)
+ {
+ case AF_INET:
+@@ -1196,7 +1207,9 @@ static int same_address(struct sockaddr *sa, struct ares_addr *aa)
+ default:
+ break;
+ }
++#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
+ }
++#endif
+ return 0; /* different */
+ }
+
+--
+1.7.2.1
+
diff --git a/0001-fix-memory-leak-in-ares_getnameinfo.patch b/0001-fix-memory-leak-in-ares_getnameinfo.patch
new file mode 100644
index 0000000..480fa6c
--- /dev/null
+++ b/0001-fix-memory-leak-in-ares_getnameinfo.patch
@@ -0,0 +1,32 @@
+From d6b869894190e15960987786d337dc8d42f8285b Mon Sep 17 00:00:00 2001
+From: Andrew C. Morrow <andrew.c.morrow at gmail.com>
+Date: Wed, 16 Jun 2010 10:18:24 +0800
+Subject: [PATCH] fix memory leak in ares_getnameinfo
+
+---
+ ares_getnameinfo.c | 2 ++
+ 1 files changed, 2 insertions(+), 0 deletions(-)
+
+diff --git a/ares_getnameinfo.c b/ares_getnameinfo.c
+index fc4b7fa..8ae2f02 100644
+--- a/ares_getnameinfo.c
++++ b/ares_getnameinfo.c
+@@ -243,6 +243,7 @@ static void nameinfo_callback(void *arg, int status, int timeouts,
+ niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts,
+ (char *)(host->h_name),
+ service);
++ free(niquery);
+ return;
+ }
+ /* We couldn't find the host, but it's OK, we can use the IP */
+@@ -273,6 +274,7 @@ static void nameinfo_callback(void *arg, int status, int timeouts,
+ }
+ niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf,
+ service);
++ free(niquery);
+ return;
+ }
+ niquery->callback(niquery->arg, status, niquery->timeouts, NULL, NULL);
+--
+1.7.2.1
+
diff --git a/c-ares.spec b/c-ares.spec
index 76a06ec..94728c8 100644
--- a/c-ares.spec
+++ b/c-ares.spec
@@ -1,7 +1,7 @@
Summary: A library that performs asynchronous DNS operations
Name: c-ares
Version: 1.7.3
-Release: 1%{?dist}
+Release: 2%{?dist}
License: MIT
Group: System Environment/Libraries
URL: http://c-ares.haxx.se/
@@ -9,6 +9,11 @@ Source0: http://c-ares.haxx.se/c-ares-%{version}.tar.gz
Source1: LICENSE
Patch0: %{name}-1.7.0-optflags.patch
Patch1: c-ares-multilib.patch
+# upstream patches from 1.4 development
+Patch2: 0001-Add-missing-break-that-caused-get_ares_servers-to-fa.patch
+Patch3: 0001-fix-memory-leak-in-ares_getnameinfo.patch
+Patch4: 0001-Fix-aliasing-warning-in-gcc-4.4.4-at-least.patch
+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
@@ -66,6 +71,9 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man3/ares_*
%changelog
+* Wed Aug 25 2010 Jakub Hrozek <jhrozek at redhat.com> - 1.7.3-2
+- apply couple of patches from upstream
+
* Tue Jun 15 2010 Jakub Hrozek <jhrozek at redhat.com> - 1.7.3-1
- Upgrade to new upstream release 1.7.3 (obsoletes search/domain patch)
- Fix conflict of -devel packages on multilib architectures (#602880)
More information about the scm-commits
mailing list