summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Timo Gurr <tgurr@exherbo.org> 2020-10-21 11:57:56 +0200
committerAvatar Timo Gurr <tgurr@exherbo.org> 2020-10-21 12:21:16 +0000
commit9a0ca8fff307010ee0b2d50a77cd4e3daf417ba2 (patch)
tree292659c611ba64c6278b00c32dc3bcb90fd24bbc
parentb3e91acb1cc31ae41308f3fe3e8c493fb0e89a96 (diff)
downloadarbor-9a0ca8fff307010ee0b2d50a77cd4e3daf417ba2.tar.gz
arbor-9a0ca8fff307010ee0b2d50a77cd4e3daf417ba2.tar.xz
c-ares: add upstream backport to allow parsing of CAA Resource Records
Required for nodejs >= 15.0.0 and there's no new c-ares release yet.
-rw-r--r--packages/net-dns/c-ares/c-ares-1.16.1-r1.exheres-0 (renamed from packages/net-dns/c-ares/c-ares-1.16.1.exheres-0)6
-rw-r--r--packages/net-dns/c-ares/files/c-ares-1.16.1-caa-reply-backport.patch395
2 files changed, 401 insertions, 0 deletions
diff --git a/packages/net-dns/c-ares/c-ares-1.16.1.exheres-0 b/packages/net-dns/c-ares/c-ares-1.16.1-r1.exheres-0
index 18f1d7823..25982468a 100644
--- a/packages/net-dns/c-ares/c-ares-1.16.1.exheres-0
+++ b/packages/net-dns/c-ares/c-ares-1.16.1-r1.exheres-0
@@ -1,6 +1,8 @@
# Copyright 2008, 2011 Ingmar Vanhassel <ingmar@exherbo.org>
# Distributed under the terms of the GNU General Public License v2
+require autotools [ supported_autoconf=[ 2.5 ] supported_automake=[ 1.16 ] ]
+
SUMMARY="A C library that performs DNS requests and name resolves asynchronously"
DESCRIPTION="
c-ares is a C library that performs DNS requests and name resolves asynchronously.
@@ -16,6 +18,10 @@ MYOPTIONS="debug"
DEPENDENCIES=""
+DEFAULT_SRC_PREPARE_PATCHES=(
+ "${FILES}"/${PN}-1.16.1-caa-reply-backport.patch
+)
+
src_configure() {
local args=(
--disable-static
diff --git a/packages/net-dns/c-ares/files/c-ares-1.16.1-caa-reply-backport.patch b/packages/net-dns/c-ares/files/c-ares-1.16.1-caa-reply-backport.patch
new file mode 100644
index 000000000..c6ea91817
--- /dev/null
+++ b/packages/net-dns/c-ares/files/c-ares-1.16.1-caa-reply-backport.patch
@@ -0,0 +1,395 @@
+Source/Upstream: Yes, fixed in git master
+Reason: Backport of f5b4c0851027286ef56b84a13c85424fe25c3703 required for nodejs >= 15.0.0
+
+diff -Naur c-ares-1.16.1/adig.c c-ares-1.16.1.new/adig.c
+--- c-ares-1.16.1/adig.c 2019-08-06 16:29:37.000000000 +0200
++++ c-ares-1.16.1.new/adig.c 2020-10-21 11:49:23.067110848 +0200
+@@ -83,6 +83,9 @@
+ #ifndef T_DNSKEY
+ # define T_DNSKEY 48 /* DNS Public Key (RFC4034) */
+ #endif
++#ifndef T_CAA
++# define T_CAA 257 /* Certification Authority Authorization */
++#endif
+
+ struct nv {
+ const char *name;
+@@ -147,6 +150,7 @@
+ { "RRSIG", T_RRSIG },
+ { "NSEC", T_NSEC },
+ { "DNSKEY", T_DNSKEY },
++ { "CAA", T_CAA },
+ { "ANY", T_ANY }
+ };
+ static const int ntypes = sizeof(types) / sizeof(types[0]);
+@@ -529,6 +533,7 @@
+ const unsigned char *p;
+ int type, dnsclass, ttl, dlen, status;
+ long len;
++ int vlen;
+ char addr[46];
+ union {
+ unsigned char * as_uchar;
+@@ -684,6 +689,35 @@
+ }
+ break;
+
++ case T_CAA:
++
++ p = aptr;
++
++ /* Flags */
++ printf(" %u", (int)*p);
++ p += 1;
++
++ /* Remainder of record */
++ vlen = (int)dlen - ((char)*p) - 2;
++
++ /* The Property identifier, one of:
++ - "issue",
++ - "iodef", or
++ - "issuewild" */
++ status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
++ if (status != ARES_SUCCESS)
++ return NULL;
++ printf(" %s", name.as_char);
++ ares_free_string(name.as_char);
++ p += len;
++
++ if (p + vlen > abuf + alen)
++ return NULL;
++
++ /* A sequence of octets representing the Property Value */
++ printf(" %.*s", vlen, p);
++ break;
++
+ case T_A:
+ /* The RR data is a four-byte Internet address. */
+ if (dlen != 4)
+diff -Naur c-ares-1.16.1/ares_data.c c-ares-1.16.1.new/ares_data.c
+--- c-ares-1.16.1/ares_data.c 2018-02-07 13:13:59.000000000 +0100
++++ c-ares-1.16.1.new/ares_data.c 2020-10-21 11:32:48.887557217 +0200
+@@ -119,6 +119,16 @@
+ ares_free(ptr->data.soa_reply.hostmaster);
+ break;
+
++ case ARES_DATATYPE_CAA_REPLY:
++
++ if (ptr->data.caa_reply.next)
++ next_data = ptr->data.caa_reply.next;
++ if (ptr->data.caa_reply.property)
++ ares_free(ptr->data.caa_reply.property);
++ if (ptr->data.caa_reply.value)
++ ares_free(ptr->data.caa_reply.value);
++ break;
++
+ default:
+ return;
+ }
+@@ -174,6 +184,14 @@
+ ptr->data.txt_reply.length = 0;
+ break;
+
++ case ARES_DATATYPE_CAA_REPLY:
++ ptr->data.caa_reply.next = NULL;
++ ptr->data.caa_reply.plength = 0;
++ ptr->data.caa_reply.property = NULL;
++ ptr->data.caa_reply.length = 0;
++ ptr->data.caa_reply.value = NULL;
++ break;
++
+ case ARES_DATATYPE_ADDR_NODE:
+ ptr->data.addr_node.next = NULL;
+ ptr->data.addr_node.family = 0;
+diff -Naur c-ares-1.16.1/ares_data.h c-ares-1.16.1.new/ares_data.h
+--- c-ares-1.16.1/ares_data.h 2017-07-03 11:04:19.000000000 +0200
++++ c-ares-1.16.1.new/ares_data.h 2020-10-21 11:33:49.540014902 +0200
+@@ -30,6 +30,7 @@
+ ARES_DATATYPE_OPTIONS, /* struct ares_options */
+ #endif
+ ARES_DATATYPE_ADDR_PORT_NODE, /* struct ares_addr_port_node - introduced in 1.11.0 */
++ ARES_DATATYPE_CAA_REPLY, /* struct ares_caa_reply - introduced in 1.17 */
+ ARES_DATATYPE_LAST /* not used - introduced in 1.7.0 */
+ } ares_datatype;
+
+@@ -65,6 +66,7 @@
+ struct ares_mx_reply mx_reply;
+ struct ares_naptr_reply naptr_reply;
+ struct ares_soa_reply soa_reply;
++ struct ares_caa_reply caa_reply;
+ } data;
+ };
+
+diff -Naur c-ares-1.16.1/ares.h c-ares-1.16.1.new/ares.h
+--- c-ares-1.16.1/ares.h 2019-08-06 16:29:37.000000000 +0200
++++ c-ares-1.16.1.new/ares.h 2020-10-21 11:30:59.557551430 +0200
+@@ -528,6 +528,15 @@
+ int ttl;
+ };
+
++struct ares_caa_reply {
++ struct ares_caa_reply *next;
++ int critical;
++ unsigned char *property;
++ size_t plength; /* plength excludes null termination */
++ unsigned char *value;
++ size_t length; /* length excludes null termination */
++};
++
+ struct ares_srv_reply {
+ struct ares_srv_reply *next;
+ char *host;
+@@ -637,6 +646,10 @@
+ struct ares_addr6ttl *addrttls,
+ int *naddrttls);
+
++CARES_EXTERN int ares_parse_caa_reply(const unsigned char* abuf,
++ int alen,
++ struct ares_caa_reply** caa_out);
++
+ CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf,
+ int alen,
+ const void *addr,
+diff -Naur c-ares-1.16.1/ares_parse_caa_reply.c c-ares-1.16.1.new/ares_parse_caa_reply.c
+--- c-ares-1.16.1/ares_parse_caa_reply.c 1970-01-01 01:00:00.000000000 +0100
++++ c-ares-1.16.1.new/ares_parse_caa_reply.c 2020-10-21 11:34:40.932559859 +0200
+@@ -0,0 +1,209 @@
++
++/* Copyright 2020 by <danny.sonnenschein@platynum.ch>
++ *
++ * Permission to use, copy, modify, and distribute this
++ * software and its documentation for any purpose and without
++ * fee is hereby granted, provided that the above copyright
++ * notice appear in all copies and that both that copyright
++ * notice and this permission notice appear in supporting
++ * documentation, and that the name of M.I.T. not be used in
++ * advertising or publicity pertaining to distribution of the
++ * software without specific, written prior permission.
++ * M.I.T. makes no representations about the suitability of
++ * this software for any purpose. It is provided "as is"
++ * without express or implied warranty.
++ */
++
++#include "ares_setup.h"
++
++#ifdef HAVE_NETINET_IN_H
++# include <netinet/in.h>
++#endif
++#ifdef HAVE_NETDB_H
++# include <netdb.h>
++#endif
++#ifdef HAVE_ARPA_INET_H
++# include <arpa/inet.h>
++#endif
++#ifdef HAVE_ARPA_NAMESER_H
++# include <arpa/nameser.h>
++#else
++# include "nameser.h"
++#endif
++#ifdef HAVE_ARPA_NAMESER_COMPAT_H
++# include <arpa/nameser_compat.h>
++#endif
++
++#ifdef HAVE_STRINGS_H
++# include <strings.h>
++#endif
++
++#include "ares.h"
++#include "ares_dns.h"
++#include "ares_data.h"
++#include "ares_private.h"
++
++#ifndef T_CAA
++# define T_CAA 257 /* Certification Authority Authorization */
++#endif
++
++int
++ares_parse_caa_reply (const unsigned char *abuf, int alen,
++ struct ares_caa_reply **caa_out)
++{
++ unsigned int qdcount, ancount, i;
++ const unsigned char *aptr;
++ const unsigned char *strptr;
++ int status, rr_type, rr_class, rr_len;
++ long len;
++ char *hostname = NULL, *rr_name = NULL;
++ struct ares_caa_reply *caa_head = NULL;
++ struct ares_caa_reply *caa_last = NULL;
++ struct ares_caa_reply *caa_curr;
++
++ /* Set *caa_out to NULL for all failure cases. */
++ *caa_out = NULL;
++
++ /* Give up if abuf doesn't have room for a header. */
++ if (alen < HFIXEDSZ)
++ return ARES_EBADRESP;
++
++ /* Fetch the question and answer count from the header. */
++ qdcount = DNS_HEADER_QDCOUNT (abuf);
++ ancount = DNS_HEADER_ANCOUNT (abuf);
++ if (qdcount != 1)
++ return ARES_EBADRESP;
++ if (ancount == 0)
++ return ARES_ENODATA;
++
++ /* Expand the name from the question, and skip past the question. */
++ aptr = abuf + HFIXEDSZ;
++ status = ares_expand_name (aptr, abuf, alen, &hostname, &len);
++ if (status != ARES_SUCCESS)
++ return status;
++
++ if (aptr + len + QFIXEDSZ > abuf + alen)
++ {
++ ares_free (hostname);
++ return ARES_EBADRESP;
++ }
++ aptr += len + QFIXEDSZ;
++
++ /* Examine each answer resource record (RR) in turn. */
++ for (i = 0; i < ancount; i++)
++ {
++ /* Decode the RR up to the data field. */
++ status = ares_expand_name (aptr, abuf, alen, &rr_name, &len);
++ if (status != ARES_SUCCESS)
++ {
++ break;
++ }
++ aptr += len;
++ if (aptr + RRFIXEDSZ > abuf + alen)
++ {
++ status = ARES_EBADRESP;
++ break;
++ }
++ rr_type = DNS_RR_TYPE (aptr);
++ rr_class = DNS_RR_CLASS (aptr);
++ rr_len = DNS_RR_LEN (aptr);
++ aptr += RRFIXEDSZ;
++ if (aptr + rr_len > abuf + alen)
++ {
++ status = ARES_EBADRESP;
++ break;
++ }
++
++ /* Check if we are really looking at a CAA record */
++ if ((rr_class == C_IN || rr_class == C_CHAOS) && rr_type == T_CAA)
++ {
++ strptr = aptr;
++
++ /* Allocate storage for this CAA answer appending it to the list */
++ caa_curr = ares_malloc_data(ARES_DATATYPE_CAA_REPLY);
++ if (!caa_curr)
++ {
++ status = ARES_ENOMEM;
++ break;
++ }
++ if (caa_last)
++ {
++ caa_last->next = caa_curr;
++ }
++ else
++ {
++ caa_head = caa_curr;
++ }
++ caa_last = caa_curr;
++ if (rr_len < 2)
++ {
++ status = ARES_EBADRESP;
++ break;
++ }
++ caa_curr->critical = (int)*strptr++;
++ caa_curr->plength = (int)*strptr++;
++ if (caa_curr->plength <= 0 || (int)caa_curr->plength >= rr_len - 2)
++ {
++ status = ARES_EBADRESP;
++ break;
++ }
++ caa_curr->property = ares_malloc (caa_curr->plength + 1/* Including null byte */);
++ if (caa_curr->property == NULL)
++ {
++ status = ARES_ENOMEM;
++ break;
++ }
++ memcpy ((char *) caa_curr->property, strptr, caa_curr->plength);
++ /* Make sure we NULL-terminate */
++ caa_curr->property[caa_curr->plength] = 0;
++ strptr += caa_curr->plength;
++
++ caa_curr->length = rr_len - caa_curr->plength - 2;
++ if (caa_curr->length <= 0)
++ {
++ status = ARES_EBADRESP;
++ break;
++ }
++ caa_curr->value = ares_malloc (caa_curr->length + 1/* Including null byte */);
++ if (caa_curr->value == NULL)
++ {
++ status = ARES_ENOMEM;
++ break;
++ }
++ memcpy ((char *) caa_curr->value, strptr, caa_curr->length);
++ /* Make sure we NULL-terminate */
++ caa_curr->value[caa_curr->length] = 0;
++ }
++
++ /* Propagate any failures */
++ if (status != ARES_SUCCESS)
++ {
++ break;
++ }
++
++ /* Don't lose memory in the next iteration */
++ ares_free (rr_name);
++ rr_name = NULL;
++
++ /* Move on to the next record */
++ aptr += rr_len;
++ }
++
++ if (hostname)
++ ares_free (hostname);
++ if (rr_name)
++ ares_free (rr_name);
++
++ /* clean up on error */
++ if (status != ARES_SUCCESS)
++ {
++ if (caa_head)
++ ares_free_data (caa_head);
++ return status;
++ }
++
++ /* everything looks fine, return the data */
++ *caa_out = caa_head;
++
++ return ARES_SUCCESS;
++}
+diff -Naur c-ares-1.16.1/Makefile.inc c-ares-1.16.1.new/Makefile.inc
+--- c-ares-1.16.1/Makefile.inc 2019-08-06 16:29:37.000000000 +0200
++++ c-ares-1.16.1.new/Makefile.inc 2020-10-21 11:31:32.750247116 +0200
+@@ -31,6 +31,7 @@
+ ares_options.c \
+ ares_parse_a_reply.c \
+ ares_parse_aaaa_reply.c \
++ ares_parse_caa_reply.c \
+ ares_parse_mx_reply.c \
+ ares_parse_naptr_reply.c \
+ ares_parse_ns_reply.c \
+diff -Naur c-ares-1.16.1/nameser.h c-ares-1.16.1.new/nameser.h
+--- c-ares-1.16.1/nameser.h 2017-07-03 11:04:19.000000000 +0200
++++ c-ares-1.16.1.new/nameser.h 2020-10-21 11:35:52.146935327 +0200
+@@ -88,6 +88,7 @@
+ ns_t_maila = 254, /* Transfer mail agent records. */
+ ns_t_any = 255, /* Wildcard match. */
+ ns_t_zxfr = 256, /* BIND-specific, nonstandard. */
++ ns_t_caa = 257, /* Certification Authority Authorization. */
+ ns_t_max = 65536
+ } ns_type;
+
+@@ -204,6 +205,7 @@
+ #define T_AXFR ns_t_axfr
+ #define T_MAILB ns_t_mailb
+ #define T_MAILA ns_t_maila
++#define T_CAA ns_t_caa
+ #define T_ANY ns_t_any
+
+ #endif /* HAVE_ARPA_NAMESER_COMPAT_H */