[rt36039]
3902. bug] liblwres wasn't handling link-local addresses in
nameserver clauses in resolv.conf. [RT #36039]
(cherry picked from commit 70be388974)
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,3 +1,6 @@
|
||||
3902. bug] liblwres wasn't handling link-local addresses in
|
||||
nameserver clauses in resolv.conf. [RT #36039]
|
||||
|
||||
3901. [protocol] Added support for CAA record type (RFC 6844).
|
||||
[RT #36625]
|
||||
|
||||
|
||||
@@ -613,7 +613,8 @@ addr2af(int lwresaddrtype)
|
||||
static void
|
||||
copy_server_list(lwres_conf_t *confdata, dig_serverlist_t *dest) {
|
||||
dig_server_t *newsrv;
|
||||
char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
|
||||
char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") +
|
||||
sizeof("%4000000000")];
|
||||
int af;
|
||||
int i;
|
||||
|
||||
@@ -628,6 +629,12 @@ copy_server_list(lwres_conf_t *confdata, dig_serverlist_t *dest) {
|
||||
|
||||
lwres_net_ntop(af, confdata->nameservers[i].address,
|
||||
tmp, sizeof(tmp));
|
||||
if (af == AF_INET6 && confdata->nameservers[i].zone != 0) {
|
||||
char buf[sizeof("%4000000000")];
|
||||
snprintf(buf, sizeof(buf), "%%%u",
|
||||
confdata->nameservers[i].zone);
|
||||
strlcat(tmp, buf, sizeof(tmp));
|
||||
}
|
||||
newsrv = make_server(tmp, tmp);
|
||||
ISC_LINK_INIT(newsrv, link);
|
||||
ISC_LIST_ENQUEUE(*dest, newsrv, link);
|
||||
|
||||
@@ -242,6 +242,9 @@ int sigwait(const unsigned int *set, int *sig);
|
||||
/* Define to 1 if you have the <gssapi_krb5.h> header file. */
|
||||
#undef HAVE_GSSAPI_KRB5_H
|
||||
|
||||
/* Define to 1 if you have the `if_nametoindex' function. */
|
||||
#undef HAVE_IF_NAMETOINDEX
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
|
||||
9
configure
vendored
9
configure
vendored
@@ -732,6 +732,7 @@ ISC_PLATFORM_NEEDSPRINTF
|
||||
READLINE_LIB
|
||||
ISC_PLATFORM_NEEDSTRCASESTR
|
||||
ISC_PLATFORM_NEEDSTRLCAT
|
||||
LWRES_PLATFORM_NEEDSTRLCPY
|
||||
ISC_PLATFORM_NEEDSTRLCPY
|
||||
GENRANDOMLIB
|
||||
LWRES_PLATFORM_NEEDSTRTOUL
|
||||
@@ -18273,12 +18274,15 @@ fi
|
||||
ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy"
|
||||
if test "x$ac_cv_func_strlcpy" = xyes; then :
|
||||
ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"
|
||||
LWRES_PLATFORM_NEEDSTRLCPY="#undef LWRES_PLATFORM_NEEDSTRLCPY"
|
||||
else
|
||||
ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"
|
||||
LWRES_PLATFORM_NEEDSTRLCPY="#define LWRES_PLATFORM_NEEDSTRLCPY 1"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
|
||||
if test "x$ac_cv_func_strlcat" = xyes; then :
|
||||
ISC_PLATFORM_NEEDSTRLCAT="#undef ISC_PLATFORM_NEEDSTRLCAT"
|
||||
@@ -19061,6 +19065,8 @@ esac
|
||||
case $ac_cv_have_if_nametoindex in
|
||||
yes)
|
||||
ISC_PLATFORM_HAVEIFNAMETOINDEX="#define ISC_PLATFORM_HAVEIFNAMETOINDEX 1"
|
||||
$as_echo "#define HAVE_IF_NAMETOINDEX 1" >>confdefs.h
|
||||
|
||||
;;
|
||||
*)
|
||||
ISC_PLATFORM_HAVEIFNAMETOINDEX="#undef ISC_PLATFORM_HAVEIFNAMETOINDEX"
|
||||
@@ -21597,7 +21603,7 @@ ac_config_commands="$ac_config_commands chmod"
|
||||
# elsewhere if there's a good reason for doing so.
|
||||
#
|
||||
|
||||
ac_config_files="$ac_config_files make/Makefile make/mkdep Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/delv/Makefile bin/dig/Makefile bin/dnssec/Makefile bin/named/Makefile bin/named/unix/Makefile bin/nsupdate/Makefile bin/pkcs11/Makefile bin/python/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/rndc/Makefile bin/tests/Makefile bin/tests/atomic/Makefile bin/tests/db/Makefile bin/tests/dst/Makefile bin/tests/dst/Kdh.+002+18602.key bin/tests/dst/Kdh.+002+18602.private bin/tests/dst/Kdh.+002+48957.key bin/tests/dst/Kdh.+002+48957.private bin/tests/dst/Ktest.+001+00002.key bin/tests/dst/Ktest.+001+54622.key bin/tests/dst/Ktest.+001+54622.private bin/tests/dst/Ktest.+003+23616.key bin/tests/dst/Ktest.+003+23616.private bin/tests/dst/Ktest.+003+49667.key bin/tests/dst/dst_2_data bin/tests/dst/t2_data_1 bin/tests/dst/t2_data_2 bin/tests/dst/t2_dsasig bin/tests/dst/t2_rsasig bin/tests/hashes/Makefile bin/tests/headerdep_test.sh bin/tests/master/Makefile bin/tests/mem/Makefile bin/tests/names/Makefile bin/tests/net/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/rbt/Makefile bin/tests/resolver/Makefile bin/tests/sockaddr/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlz/prereq.sh bin/tests/system/dlzexternal/Makefile bin/tests/system/dlzexternal/ns1/named.conf bin/tests/system/dlzredir/prereq.sh bin/tests/system/filter-aaaa/Makefile bin/tests/system/geoip/Makefile bin/tests/system/inline/checkdsa.sh bin/tests/system/lwresd/Makefile bin/tests/system/sit/prereq.sh bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile bin/tests/system/tsiggss/Makefile bin/tests/tasks/Makefile bin/tests/timers/Makefile bin/tests/virtual-time/Makefile bin/tests/virtual-time/conf.sh bin/tools/Makefile contrib/scripts/check-secure-delegation.pl contrib/scripts/zone-edit.sh doc/Makefile doc/arm/Makefile doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/misc/Makefile doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-docbook-latex.xsl doc/xsl/isc-manpage.xsl isc-config.sh lib/Makefile lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/dns/tests/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/isc/$arch/Makefile lib/isc/$arch/include/Makefile lib/isc/$arch/include/isc/Makefile lib/isc/$thread_dir/Makefile lib/isc/$thread_dir/include/Makefile lib/isc/$thread_dir/include/isc/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/include/pk11/Makefile lib/isc/include/pkcs11/Makefile lib/isc/tests/Makefile lib/isc/nls/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isc/unix/include/pkcs11/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/lwres/Makefile lib/lwres/include/Makefile lib/lwres/include/lwres/Makefile lib/lwres/include/lwres/netdb.h lib/lwres/include/lwres/platform.h lib/lwres/man/Makefile lib/lwres/unix/Makefile lib/lwres/unix/include/Makefile lib/lwres/unix/include/lwres/Makefile lib/tests/Makefile lib/tests/include/Makefile lib/tests/include/tests/Makefile lib/samples/Makefile lib/samples/Makefile-postinstall unit/Makefile unit/unittest.sh"
|
||||
ac_config_files="$ac_config_files make/Makefile make/mkdep Makefile bin/Makefile bin/check/Makefile bin/confgen/Makefile bin/confgen/unix/Makefile bin/delv/Makefile bin/dig/Makefile bin/dnssec/Makefile bin/named/Makefile bin/named/unix/Makefile bin/nsupdate/Makefile bin/pkcs11/Makefile bin/python/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/rndc/Makefile bin/tests/Makefile bin/tests/atomic/Makefile bin/tests/db/Makefile bin/tests/dst/Makefile bin/tests/dst/Kdh.+002+18602.key bin/tests/dst/Kdh.+002+18602.private bin/tests/dst/Kdh.+002+48957.key bin/tests/dst/Kdh.+002+48957.private bin/tests/dst/Ktest.+001+00002.key bin/tests/dst/Ktest.+001+54622.key bin/tests/dst/Ktest.+001+54622.private bin/tests/dst/Ktest.+003+23616.key bin/tests/dst/Ktest.+003+23616.private bin/tests/dst/Ktest.+003+49667.key bin/tests/dst/dst_2_data bin/tests/dst/t2_data_1 bin/tests/dst/t2_data_2 bin/tests/dst/t2_dsasig bin/tests/dst/t2_rsasig bin/tests/hashes/Makefile bin/tests/headerdep_test.sh bin/tests/master/Makefile bin/tests/mem/Makefile bin/tests/names/Makefile bin/tests/net/Makefile bin/tests/pkcs11/Makefile bin/tests/pkcs11/benchmarks/Makefile bin/tests/rbt/Makefile bin/tests/resolver/Makefile bin/tests/sockaddr/Makefile bin/tests/system/Makefile bin/tests/system/conf.sh bin/tests/system/dlz/prereq.sh bin/tests/system/dlzexternal/Makefile bin/tests/system/dlzexternal/ns1/named.conf bin/tests/system/dlzredir/prereq.sh bin/tests/system/filter-aaaa/Makefile bin/tests/system/geoip/Makefile bin/tests/system/inline/checkdsa.sh bin/tests/system/lwresd/Makefile bin/tests/system/sit/prereq.sh bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/tkey/Makefile bin/tests/system/tsiggss/Makefile bin/tests/tasks/Makefile bin/tests/timers/Makefile bin/tests/virtual-time/Makefile bin/tests/virtual-time/conf.sh bin/tools/Makefile contrib/scripts/check-secure-delegation.pl contrib/scripts/zone-edit.sh doc/Makefile doc/arm/Makefile doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/misc/Makefile doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-docbook-latex.xsl doc/xsl/isc-manpage.xsl isc-config.sh lib/Makefile lib/bind9/Makefile lib/bind9/include/Makefile lib/bind9/include/bind9/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/dns/tests/Makefile lib/irs/Makefile lib/irs/include/Makefile lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h lib/isc/$arch/Makefile lib/isc/$arch/include/Makefile lib/isc/$arch/include/isc/Makefile lib/isc/$thread_dir/Makefile lib/isc/$thread_dir/include/Makefile lib/isc/$thread_dir/include/isc/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/include/pk11/Makefile lib/isc/include/pkcs11/Makefile lib/isc/tests/Makefile lib/isc/nls/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isc/unix/include/pkcs11/Makefile lib/isccc/Makefile lib/isccc/include/Makefile lib/isccc/include/isccc/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/lwres/Makefile lib/lwres/include/Makefile lib/lwres/include/lwres/Makefile lib/lwres/include/lwres/netdb.h lib/lwres/include/lwres/platform.h lib/lwres/man/Makefile lib/lwres/tests/Makefile lib/lwres/unix/Makefile lib/lwres/unix/include/Makefile lib/lwres/unix/include/lwres/Makefile lib/tests/Makefile lib/tests/include/Makefile lib/tests/include/tests/Makefile lib/samples/Makefile lib/samples/Makefile-postinstall unit/Makefile unit/unittest.sh"
|
||||
|
||||
|
||||
#
|
||||
@@ -22717,6 +22723,7 @@ do
|
||||
"lib/lwres/include/lwres/netdb.h") CONFIG_FILES="$CONFIG_FILES lib/lwres/include/lwres/netdb.h" ;;
|
||||
"lib/lwres/include/lwres/platform.h") CONFIG_FILES="$CONFIG_FILES lib/lwres/include/lwres/platform.h" ;;
|
||||
"lib/lwres/man/Makefile") CONFIG_FILES="$CONFIG_FILES lib/lwres/man/Makefile" ;;
|
||||
"lib/lwres/tests/Makefile") CONFIG_FILES="$CONFIG_FILES lib/lwres/tests/Makefile" ;;
|
||||
"lib/lwres/unix/Makefile") CONFIG_FILES="$CONFIG_FILES lib/lwres/unix/Makefile" ;;
|
||||
"lib/lwres/unix/include/Makefile") CONFIG_FILES="$CONFIG_FILES lib/lwres/unix/include/Makefile" ;;
|
||||
"lib/lwres/unix/include/lwres/Makefile") CONFIG_FILES="$CONFIG_FILES lib/lwres/unix/include/lwres/Makefile" ;;
|
||||
|
||||
@@ -3067,9 +3067,12 @@ AC_SUBST(LWRES_PLATFORM_NEEDSTRTOUL)
|
||||
AC_SUBST(GENRANDOMLIB)
|
||||
|
||||
AC_CHECK_FUNC(strlcpy,
|
||||
[ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"],
|
||||
[ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"])
|
||||
[ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"
|
||||
LWRES_PLATFORM_NEEDSTRLCPY="#undef LWRES_PLATFORM_NEEDSTRLCPY"],
|
||||
[ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"
|
||||
LWRES_PLATFORM_NEEDSTRLCPY="#define LWRES_PLATFORM_NEEDSTRLCPY 1"])
|
||||
AC_SUBST(ISC_PLATFORM_NEEDSTRLCPY)
|
||||
AC_SUBST(LWRES_PLATFORM_NEEDSTRLCPY)
|
||||
|
||||
AC_CHECK_FUNC(strlcat,
|
||||
[ISC_PLATFORM_NEEDSTRLCAT="#undef ISC_PLATFORM_NEEDSTRLCAT"],
|
||||
@@ -3453,6 +3456,7 @@ esac
|
||||
case $ac_cv_have_if_nametoindex in
|
||||
yes)
|
||||
ISC_PLATFORM_HAVEIFNAMETOINDEX="#define ISC_PLATFORM_HAVEIFNAMETOINDEX 1"
|
||||
AC_DEFINE(HAVE_IF_NAMETOINDEX, 1)
|
||||
;;
|
||||
*)
|
||||
ISC_PLATFORM_HAVEIFNAMETOINDEX="#undef ISC_PLATFORM_HAVEIFNAMETOINDEX"
|
||||
@@ -4550,6 +4554,7 @@ AC_CONFIG_FILES([
|
||||
lib/lwres/include/lwres/netdb.h
|
||||
lib/lwres/include/lwres/platform.h
|
||||
lib/lwres/man/Makefile
|
||||
lib/lwres/tests/Makefile
|
||||
lib/lwres/unix/Makefile
|
||||
lib/lwres/unix/include/Makefile
|
||||
lib/lwres/unix/include/lwres/Makefile
|
||||
|
||||
@@ -4,3 +4,4 @@ prop: test-suite = bind9
|
||||
|
||||
tp: dns
|
||||
tp: isc
|
||||
tp: lwres
|
||||
|
||||
5
lib/lwres/Atffile
Normal file
5
lib/lwres/Atffile
Normal file
@@ -0,0 +1,5 @@
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
prop: test-suite = bind9
|
||||
|
||||
tp: tests
|
||||
@@ -31,25 +31,25 @@ CDEFINES =
|
||||
CWARNINGS =
|
||||
|
||||
# Alphabetically
|
||||
OBJS = context.@O@ gai_strerror.@O@ getaddrinfo.@O@ gethost.@O@ \
|
||||
OBJS = compat.@O@ context.@O@ \
|
||||
gai_strerror.@O@ getaddrinfo.@O@ gethost.@O@ \
|
||||
getipnode.@O@ getnameinfo.@O@ getrrset.@O@ herror.@O@ \
|
||||
lwbuffer.@O@ lwconfig.@O@ lwpacket.@O@ lwresutil.@O@ \
|
||||
lwres_gabn.@O@ lwres_gnba.@O@ lwres_grbn.@O@ lwres_noop.@O@ \
|
||||
lwinetaton.@O@ lwinetpton.@O@ lwinetntop.@O@ print.@O@ \
|
||||
strtoul.@O@
|
||||
lwinetaton.@O@ lwinetpton.@O@ lwinetntop.@O@ print.@O@
|
||||
|
||||
# Alphabetically
|
||||
SRCS = context.c gai_strerror.c getaddrinfo.c gethost.c \
|
||||
SRCS = compat.c context.c gai_strerror.c getaddrinfo.c gethost.c \
|
||||
getipnode.c getnameinfo.c getrrset.c herror.c \
|
||||
lwbuffer.c lwconfig.c lwpacket.c lwresutil.c \
|
||||
lwres_gabn.c lwres_gnba.c lwres_grbn.c lwres_noop.c \
|
||||
lwinetaton.c lwinetpton.c lwinetntop.c print.c \
|
||||
strtoul.c
|
||||
lwinetaton.c lwinetpton.c lwinetntop.c print.c
|
||||
|
||||
LIBS = @LIBS@
|
||||
|
||||
SUBDIRS = include man unix
|
||||
TARGETS = timestamp
|
||||
TESTDIRS = @UNITTESTS@
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <lwres/stdlib.h>
|
||||
#include <lwres/compat.h>
|
||||
|
||||
#define DE_CONST(konst, var) \
|
||||
do { \
|
||||
@@ -129,3 +129,28 @@ lwres_strtoul(const char *nptr, char **endptr, int base) {
|
||||
DE_CONST(any ? s - 1 : nptr, *endptr);
|
||||
return (acc);
|
||||
}
|
||||
|
||||
size_t
|
||||
lwres_strlcpy(char *dst, const char *src, size_t size) {
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
size_t n = size;
|
||||
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0U && --n != 0U) {
|
||||
do {
|
||||
if ((*d++ = *s++) == 0)
|
||||
break;
|
||||
} while (--n != 0U);
|
||||
}
|
||||
|
||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||
if (n == 0U) {
|
||||
if (size != 0U)
|
||||
*d = '\0'; /* NUL-terminate dst */
|
||||
while (*s++)
|
||||
;
|
||||
}
|
||||
|
||||
return(s - src - 1); /* count does not include NUL */
|
||||
}
|
||||
@@ -134,13 +134,12 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/string.h>
|
||||
|
||||
#include <lwres/compat.h>
|
||||
#include <lwres/lwres.h>
|
||||
#include <lwres/net.h>
|
||||
#include <lwres/netdb.h>
|
||||
#include <lwres/stdlib.h>
|
||||
|
||||
#define SA(addr) ((struct sockaddr *)(addr))
|
||||
#define SIN(addr) ((struct sockaddr_in *)(addr))
|
||||
|
||||
@@ -24,8 +24,8 @@ top_srcdir = @top_srcdir@
|
||||
# machine generated. The latter are handled specially in the
|
||||
# install target below.
|
||||
#
|
||||
HEADERS = context.h int.h ipv6.h lang.h list.h lwbuffer.h lwpacket.h \
|
||||
lwres.h result.h stdlib.h version.h
|
||||
HEADERS = compat.h context.h int.h ipv6.h lang.h list.h \
|
||||
lwbuffer.h lwpacket.h lwres.h result.h version.h
|
||||
|
||||
SUBDIRS =
|
||||
TARGETS =
|
||||
|
||||
@@ -15,12 +15,10 @@
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: stdlib.h,v 1.6 2007/06/19 23:47:23 tbox Exp $ */
|
||||
#ifndef LWRES_COMPAT_H
|
||||
#define LWRES_COMPAT_H 1
|
||||
|
||||
#ifndef LWRES_STDLIB_H
|
||||
#define LWRES_STDLIB_H 1
|
||||
|
||||
/*! \file lwres/stdlib.h */
|
||||
/*! \file lwres/compat.h */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -31,9 +29,14 @@
|
||||
#define strtoul lwres_strtoul
|
||||
#endif
|
||||
|
||||
#ifdef LWRES_PLATFORM_NEEDSTRLCPY
|
||||
#define strlcpy lwres_strlcpy
|
||||
#endif
|
||||
|
||||
LWRES_LANG_BEGINDECLS
|
||||
|
||||
unsigned long lwres_strtoul(const char *, char **, int);
|
||||
size_t lwres_strlcpy(char *dst, const char *src, size_t size);
|
||||
|
||||
LWRES_LANG_ENDDECLS
|
||||
|
||||
@@ -121,6 +121,7 @@ struct lwres_addr {
|
||||
lwres_uint32_t family;
|
||||
lwres_uint16_t length;
|
||||
unsigned char address[LWRES_ADDR_MAXLEN];
|
||||
lwres_uint32_t zone;
|
||||
LWRES_LINK(lwres_addr_t) link;
|
||||
};
|
||||
|
||||
|
||||
@@ -100,6 +100,11 @@
|
||||
*/
|
||||
@LWRES_PLATFORM_NEEDSTRTOUL@
|
||||
|
||||
/*! \brief
|
||||
* Define if this system needs strlcpy.
|
||||
*/
|
||||
@LWRES_PLATFORM_NEEDSTRLCPY@
|
||||
|
||||
#ifndef LWRES_PLATFORM_USEDECLSPEC
|
||||
#define LIBLWRES_EXTERNAL_DATA
|
||||
#else
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
/*! \file */
|
||||
|
||||
/**
|
||||
@@ -63,6 +61,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <lwres/compat.h>
|
||||
#include <lwres/lwbuffer.h>
|
||||
#include <lwres/lwres.h>
|
||||
#include <lwres/net.h>
|
||||
@@ -204,6 +203,7 @@ lwres_resetaddr(lwres_addr_t *addr) {
|
||||
memset(addr->address, 0, LWRES_ADDR_MAXLEN);
|
||||
addr->family = 0;
|
||||
addr->length = 0;
|
||||
addr->zone = 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
@@ -449,6 +449,18 @@ static lwres_result_t
|
||||
lwres_create_addr(const char *buffer, lwres_addr_t *addr, int convert_zero) {
|
||||
struct in_addr v4;
|
||||
struct in6_addr v6;
|
||||
char buf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") +
|
||||
sizeof("%4294967295")];
|
||||
char *percent;
|
||||
size_t n;
|
||||
|
||||
n = strlcpy(buf, buffer, sizeof(buf));
|
||||
if (n >= sizeof(buf))
|
||||
return (LWRES_R_FAILURE);
|
||||
|
||||
percent = strchr(buf, '%');
|
||||
if (percent != NULL)
|
||||
*percent = 0;
|
||||
|
||||
if (lwres_net_aton(buffer, &v4) == 1) {
|
||||
if (convert_zero) {
|
||||
@@ -459,15 +471,35 @@ lwres_create_addr(const char *buffer, lwres_addr_t *addr, int convert_zero) {
|
||||
}
|
||||
addr->family = LWRES_ADDRTYPE_V4;
|
||||
addr->length = NS_INADDRSZ;
|
||||
addr->zone = 0;
|
||||
memmove((void *)addr->address, &v4, NS_INADDRSZ);
|
||||
|
||||
} else if (lwres_net_pton(AF_INET6, buffer, &v6) == 1) {
|
||||
} else if (lwres_net_pton(AF_INET6, buf, &v6) == 1) {
|
||||
addr->family = LWRES_ADDRTYPE_V6;
|
||||
addr->length = NS_IN6ADDRSZ;
|
||||
memmove((void *)addr->address, &v6, NS_IN6ADDRSZ);
|
||||
} else {
|
||||
if (percent != NULL) {
|
||||
unsigned long zone;
|
||||
char *ep;
|
||||
|
||||
percent++;
|
||||
|
||||
#ifdef HAVE_IF_NAMETOINDEX
|
||||
zone = if_nametoindex(percent);
|
||||
if (zone != 0) {
|
||||
addr->zone = zone;
|
||||
return (LWRES_R_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
zone = strtoul(percent, &ep, 10);
|
||||
if (ep != percent && *ep == 0)
|
||||
addr->zone = zone;
|
||||
else
|
||||
return (LWRES_R_FAILURE);
|
||||
} else
|
||||
addr->zone = 0;
|
||||
} else
|
||||
return (LWRES_R_FAILURE); /* Unrecognised format. */
|
||||
}
|
||||
|
||||
return (LWRES_R_SUCCESS);
|
||||
}
|
||||
@@ -630,6 +662,7 @@ lwres_conf_print(lwres_context_t *ctx, FILE *fp) {
|
||||
int i;
|
||||
int af;
|
||||
char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
|
||||
char buf[sizeof("%4000000000")];
|
||||
const char *p;
|
||||
lwres_conf_t *confdata;
|
||||
lwres_addr_t tmpaddr;
|
||||
@@ -647,7 +680,13 @@ lwres_conf_print(lwres_context_t *ctx, FILE *fp) {
|
||||
if (p != tmp)
|
||||
return (LWRES_R_FAILURE);
|
||||
|
||||
fprintf(fp, "nameserver %s\n", tmp);
|
||||
if (af == AF_INET6 && confdata->lwservers[i].zone != 0) {
|
||||
snprintf(buf, sizeof(buf), "%%%u",
|
||||
confdata->nameservers[i].zone);
|
||||
} else
|
||||
buf[0] = 0;
|
||||
|
||||
fprintf(fp, "nameserver %s%s\n", tmp, buf);
|
||||
}
|
||||
|
||||
for (i = 0; i < confdata->lwnext; i++) {
|
||||
@@ -658,7 +697,13 @@ lwres_conf_print(lwres_context_t *ctx, FILE *fp) {
|
||||
if (p != tmp)
|
||||
return (LWRES_R_FAILURE);
|
||||
|
||||
fprintf(fp, "lwserver %s\n", tmp);
|
||||
if (af == AF_INET6 && confdata->lwservers[i].zone != 0) {
|
||||
snprintf(buf, sizeof(buf), "%%%u",
|
||||
confdata->nameservers[i].zone);
|
||||
} else
|
||||
buf[0] = 0;
|
||||
|
||||
fprintf(fp, "lwserver %s%s\n", tmp, buf);
|
||||
}
|
||||
|
||||
if (confdata->domainname != NULL) {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#define LWRES__PRINT_SOURCE /* Used to get the lwres_print_* prototypes. */
|
||||
|
||||
#include <lwres/stdlib.h>
|
||||
#include <lwres/compat.h>
|
||||
|
||||
#include "assert_p.h"
|
||||
#include "print_p.h"
|
||||
|
||||
5
lib/lwres/tests/Atffile
Normal file
5
lib/lwres/tests/Atffile
Normal file
@@ -0,0 +1,5 @@
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
prop: test-suite = bind9
|
||||
|
||||
tp-glob: *_test
|
||||
54
lib/lwres/tests/Makefile.in
Normal file
54
lib/lwres/tests/Makefile.in
Normal file
@@ -0,0 +1,54 @@
|
||||
# Copyright (C) 2011-2014 Internet Systems Consortium, Inc. ("ISC")
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
# PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id$
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
||||
# Attempt to disable parallel processing.
|
||||
.NOTPARALLEL:
|
||||
.NO_PARALLEL:
|
||||
|
||||
@BIND9_VERSION@
|
||||
|
||||
@BIND9_MAKE_INCLUDES@
|
||||
|
||||
CINCLUDES = -I. -Iinclude -I../include ${LWRES_INCLUDES}
|
||||
CDEFINES = -DTESTS="\"${top_builddir}/lib/lwres/tests/\""
|
||||
|
||||
LWRESLIBS = ../liblwres.@A@
|
||||
LWRESDEPLIBS = ../liblwres.@A@
|
||||
|
||||
LIBS = @LIBS@ @ATFLIBS@
|
||||
|
||||
OBJS =
|
||||
SRCS = config_test.c
|
||||
|
||||
SUBDIRS =
|
||||
TARGETS = config_test@EXEEXT@
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
config_test@EXEEXT@: config_test.@O@ ${LWRESDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
config_test.@O@ ${LWRESLIBS} ${LIBS}
|
||||
|
||||
unit::
|
||||
sh ${top_srcdir}/unit/unittest.sh
|
||||
|
||||
clean distclean::
|
||||
rm -f ${TARGETS}
|
||||
rm -f atf.out
|
||||
73
lib/lwres/tests/config_test.c
Normal file
73
lib/lwres/tests/config_test.c
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
|
||||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
||||
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../lwconfig.c"
|
||||
|
||||
static void
|
||||
setup_test() {
|
||||
/*
|
||||
* atf-run changes us to a /tmp directory, so tests
|
||||
* that access test data files must first chdir to the proper
|
||||
* location.
|
||||
*/
|
||||
ATF_CHECK(chdir(TESTS) != -1);
|
||||
}
|
||||
|
||||
ATF_TC(parse_linklocal);
|
||||
ATF_TC_HEAD(parse_linklocal, tc) {
|
||||
atf_tc_set_md_var(tc, "descr", "lwres_conf_parse link-local nameserver");
|
||||
}
|
||||
ATF_TC_BODY(parse_linklocal, tc) {
|
||||
lwres_result_t result;
|
||||
lwres_context_t *ctx = NULL;
|
||||
unsigned char addr[16] = { 0xfe, 0x80, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01 };
|
||||
|
||||
UNUSED(tc);
|
||||
|
||||
setup_test();
|
||||
|
||||
lwres_context_create(&ctx, NULL, NULL, NULL,
|
||||
LWRES_CONTEXT_USEIPV4 | LWRES_CONTEXT_USEIPV6);
|
||||
ATF_CHECK_EQ(ctx->confdata.nsnext, 0);
|
||||
ATF_CHECK_EQ(ctx->confdata.nameservers[0].zone, 0);
|
||||
|
||||
result = lwres_conf_parse(ctx, "testdata/link-local.conf");
|
||||
ATF_CHECK_EQ(result, LWRES_R_SUCCESS);
|
||||
ATF_CHECK_EQ(ctx->confdata.nsnext, 1);
|
||||
ATF_CHECK_EQ(ctx->confdata.nameservers[0].zone, 1);
|
||||
ATF_CHECK_EQ(memcmp(ctx->confdata.nameservers[0].address, addr, 16), 0);
|
||||
lwres_context_destroy(&ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
ATF_TP_ADD_TCS(tp) {
|
||||
ATF_TP_ADD_TC(tp, parse_linklocal);
|
||||
return (atf_no_error());
|
||||
}
|
||||
1
lib/lwres/tests/testdata/link-local.conf
vendored
Normal file
1
lib/lwres/tests/testdata/link-local.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
nameserver fe80::1%1
|
||||
Reference in New Issue
Block a user