diff --git a/CHANGES b/CHANGES index ce43fac4ab..e245bc1c29 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4492. [bug] irs_resconf_load failed to initialise sortlistnxt + causing bad writes if resolv.conf contained a + sortlist directive. [RT #43459] + 4491. [bug] Improve message emitted when testing whether sendmsg works with TOS/TCLASS fails. [RT #43483] diff --git a/configure b/configure index e98c55980d..90f8465fca 100755 --- a/configure +++ b/configure @@ -23149,7 +23149,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/isc/Makefile bin/python/isc/utils.py bin/python/isc/tests/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/python/dnssec-keymgr.py bin/python/isc/__init__.py bin/python/isc/checkds.py bin/python/isc/coverage.py bin/python/isc/dnskey.py bin/python/isc/eventlist.py bin/python/isc/keydict.py bin/python/isc/keyevent.py bin/python/isc/keymgr.py bin/python/isc/keyseries.py bin/python/isc/keyzone.py bin/python/isc/policy.py bin/python/isc/rndc.py bin/python/isc/tests/dnskey_test.py bin/python/isc/tests/policy_test.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/builtin/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/dyndb/Makefile bin/tests/system/dyndb/driver/Makefile 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/pipelined/Makefile bin/tests/system/resolver/Makefile bin/tests/system/rndc/Makefile bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/statistics/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/arm/noteversion.xml doc/arm/pkgversion.xml doc/arm/releaseinfo.xml doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/misc/Makefile doc/tex/Makefile doc/tex/armstyle.sty doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-manpage.xsl doc/xsl/isc-notes-html.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/isccfg/tests/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" +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/isc/Makefile bin/python/isc/utils.py bin/python/isc/tests/Makefile bin/python/dnssec-checkds.py bin/python/dnssec-coverage.py bin/python/dnssec-keymgr.py bin/python/isc/__init__.py bin/python/isc/checkds.py bin/python/isc/coverage.py bin/python/isc/dnskey.py bin/python/isc/eventlist.py bin/python/isc/keydict.py bin/python/isc/keyevent.py bin/python/isc/keymgr.py bin/python/isc/keyseries.py bin/python/isc/keyzone.py bin/python/isc/policy.py bin/python/isc/rndc.py bin/python/isc/tests/dnskey_test.py bin/python/isc/tests/policy_test.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/builtin/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/dyndb/Makefile bin/tests/system/dyndb/driver/Makefile 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/pipelined/Makefile bin/tests/system/resolver/Makefile bin/tests/system/rndc/Makefile bin/tests/system/rpz/Makefile bin/tests/system/rsabigexponent/Makefile bin/tests/system/statistics/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/arm/noteversion.xml doc/arm/pkgversion.xml doc/arm/releaseinfo.xml doc/doxygen/Doxyfile doc/doxygen/Makefile doc/doxygen/doxygen-input-filter doc/misc/Makefile doc/tex/Makefile doc/tex/armstyle.sty doc/xsl/Makefile doc/xsl/isc-docbook-chunk.xsl doc/xsl/isc-docbook-html.xsl doc/xsl/isc-manpage.xsl doc/xsl/isc-notes-html.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/irs/tests/Makefile 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/isccfg/tests/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" # @@ -24267,6 +24267,7 @@ do "lib/irs/include/irs/Makefile") CONFIG_FILES="$CONFIG_FILES lib/irs/include/irs/Makefile" ;; "lib/irs/include/irs/netdb.h") CONFIG_FILES="$CONFIG_FILES lib/irs/include/irs/netdb.h" ;; "lib/irs/include/irs/platform.h") CONFIG_FILES="$CONFIG_FILES lib/irs/include/irs/platform.h" ;; + "lib/irs/tests/Makefile") CONFIG_FILES="$CONFIG_FILES lib/irs/tests/Makefile" ;; "lib/isc/$arch/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/$arch/Makefile" ;; "lib/isc/$arch/include/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/$arch/include/Makefile" ;; "lib/isc/$arch/include/isc/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/$arch/include/isc/Makefile" ;; diff --git a/configure.in b/configure.in index b1eda0f3f6..49ab0d1cde 100644 --- a/configure.in +++ b/configure.in @@ -5170,6 +5170,7 @@ AC_CONFIG_FILES([ lib/irs/include/irs/Makefile lib/irs/include/irs/netdb.h lib/irs/include/irs/platform.h + lib/irs/tests/Makefile lib/isc/$arch/Makefile lib/isc/$arch/include/Makefile lib/isc/$arch/include/isc/Makefile diff --git a/lib/Atffile b/lib/Atffile index 3f63ee1cd7..93bbb0103d 100644 --- a/lib/Atffile +++ b/lib/Atffile @@ -3,6 +3,7 @@ Content-Type: application/X-atf-atffile; version="1" prop: test-suite = bind9 tp: dns +tp: irs tp: isc tp: isccfg tp: lwres diff --git a/lib/irs/Atffile b/lib/irs/Atffile new file mode 100644 index 0000000000..1edb838c66 --- /dev/null +++ b/lib/irs/Atffile @@ -0,0 +1,5 @@ +Content-Type: application/X-atf-atffile; version="1" + +prop: test-suite = bind9 + +tp: tests diff --git a/lib/irs/Makefile.in b/lib/irs/Makefile.in index 4ebb419ef3..35b9452e7e 100644 --- a/lib/irs/Makefile.in +++ b/lib/irs/Makefile.in @@ -38,6 +38,7 @@ SRCS = context.c \ LIBS = @LIBS@ SUBDIRS = include +TESTDIRS = @UNITTESTS@ TARGETS = timestamp @BIND9_MAKE_RULES@ diff --git a/lib/irs/resconf.c b/lib/irs/resconf.c index 82ed1e29eb..0614215283 100644 --- a/lib/irs/resconf.c +++ b/lib/irs/resconf.c @@ -73,10 +73,10 @@ * resolv.conf parameters */ -#define RESCONFMAXNAMESERVERS 3 /*%< max 3 "nameserver" entries */ -#define RESCONFMAXSEARCH 8 /*%< max 8 domains in "search" entry */ -#define RESCONFMAXLINELEN 256 /*%< max size of a line */ -#define RESCONFMAXSORTLIST 10 /*%< max 10 */ +#define RESCONFMAXNAMESERVERS 3U /*%< max 3 "nameserver" entries */ +#define RESCONFMAXSEARCH 8U /*%< max 8 domains in "search" entry */ +#define RESCONFMAXLINELEN 256U /*%< max size of a line */ +#define RESCONFMAXSORTLIST 10U /*%< max 10 */ /*! * configuration data structure @@ -298,7 +298,8 @@ resconf_parsenameserver(irs_resconf_t *conf, FILE *fp) { static isc_result_t resconf_parsedomain(irs_resconf_t *conf, FILE *fp) { char word[RESCONFMAXLINELEN]; - int res, i; + int res; + unsigned int i; res = getword(fp, word, sizeof(word)); if (strlen(word) == 0U) @@ -332,7 +333,8 @@ resconf_parsedomain(irs_resconf_t *conf, FILE *fp) { static isc_result_t resconf_parsesearch(irs_resconf_t *conf, FILE *fp) { - int idx, delim; + int delim; + unsigned int idx; char word[RESCONFMAXLINELEN]; if (conf->domainname != NULL) { @@ -363,6 +365,7 @@ resconf_parsesearch(irs_resconf_t *conf, FILE *fp) { if (conf->searchnxt == RESCONFMAXSEARCH) goto ignore; /* Too many domains. */ + INSIST(idx < sizeof(conf->search)/sizeof(conf->search[0])); conf->search[idx] = isc_mem_strdup(conf->mctx, word); if (conf->search[idx] == NULL) return (ISC_R_NOMEMORY); @@ -381,7 +384,8 @@ resconf_parsesearch(irs_resconf_t *conf, FILE *fp) { static isc_result_t resconf_parsesortlist(irs_resconf_t *conf, FILE *fp) { - int delim, res, idx; + int delim, res; + unsigned int idx; char word[RESCONFMAXLINELEN]; char *p; @@ -398,6 +402,7 @@ resconf_parsesortlist(irs_resconf_t *conf, FILE *fp) { *p++ = '\0'; idx = conf->sortlistnxt; + INSIST(idx < sizeof(conf->sortlist)/sizeof(conf->sortlist[0])); res = create_addr(word, &conf->sortlist[idx].addr, 1); if (res != ISC_R_SUCCESS) return (res); @@ -481,7 +486,8 @@ irs_resconf_load(isc_mem_t *mctx, const char *filename, irs_resconf_t **confp) char word[256]; isc_result_t rval, ret = ISC_R_SUCCESS; irs_resconf_t *conf; - int i, stopchar; + unsigned int i; + int stopchar; REQUIRE(mctx != NULL); REQUIRE(filename != NULL); @@ -497,6 +503,7 @@ irs_resconf_load(isc_mem_t *mctx, const char *filename, irs_resconf_t **confp) conf->numns = 0; conf->domainname = NULL; conf->searchnxt = 0; + conf->sortlistnxt = 0; conf->resdebug = 0; conf->ndots = 1; for (i = 0; i < RESCONFMAXSEARCH; i++) @@ -548,7 +555,7 @@ irs_resconf_load(isc_mem_t *mctx, const char *filename, irs_resconf_t **confp) } /* If we don't find a nameserver fall back to localhost */ - if (conf->numns == 0) { + if (conf->numns == 0U) { INSIST(ISC_LIST_EMPTY(conf->nameservers)); /* XXX: should we catch errors? */ @@ -589,7 +596,7 @@ irs_resconf_destroy(irs_resconf_t **confp) { irs_resconf_t *conf; isc_sockaddr_t *address; irs_resconf_search_t *searchentry; - int i; + unsigned int i; REQUIRE(confp != NULL); conf = *confp; diff --git a/lib/irs/tests/Atffile b/lib/irs/tests/Atffile new file mode 100644 index 0000000000..c3e044f41a --- /dev/null +++ b/lib/irs/tests/Atffile @@ -0,0 +1,5 @@ +Content-Type: application/X-atf-atffile; version="1" + +prop: test-suite = bind9 + +tp-glob: *_test diff --git a/lib/irs/tests/Makefile.in b/lib/irs/tests/Makefile.in new file mode 100644 index 0000000000..58d797c12a --- /dev/null +++ b/lib/irs/tests/Makefile.in @@ -0,0 +1,52 @@ +# Copyright (C) 2014-2016 Internet Systems Consortium, Inc. ("ISC") +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# $Id$ + +srcdir = @srcdir@ +VPATH = @srcdir@ +top_srcdir = @top_srcdir@ + +# Attempt to disable parallel processing. +.NOTPARALLEL: +.NO_PARALLEL: + +VERSION=@BIND9_VERSION@ + +@BIND9_MAKE_INCLUDES@ + +CINCLUDES = -I. -Iinclude -I../include ${ISC_INCLUDES} +CDEFINES = -DTESTS="\"${top_builddir}/lib/irs/tests/\"" + +CFGLIBS = ../../isccfg/libisccfg.@A@ +CFGDEPLIBS = ../../isccfg/libisccfg.@A@ +DNSLIBS = ../../dns/libdns.@A@ @DNS_CRYPTO_LIBS@ +DNSDEPLIBS = ../../dns/libdns.@A@ +ISCLIBS = ../../isc/libisc.@A@ +ISCDEPLIBS = ../../isc/libisc.@A@ +IRSLIBS = ../libirs.@A@ +IRSDEPLIBS = ../libirs.@A@ + +LIBS = ${IRSLIBS} ${CFGLIBS} ${DNSLIBS} ${ISCLIBS} @LIBS@ @ATFLIBS@ + +OBJS = +SRCS = resconf_test.c + +SUBDIRS = +TARGETS = resconf_test@EXEEXT@ + +@BIND9_MAKE_RULES@ + +resconf_test@EXEEXT@: resconf_test.@O@ ${CFGDEPLIBS} ${DNSDEPLIBS} ${IRSDEPLIBS} ${ISCDEPLIBS} + ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ + resconf_test.@O@ ${LIBS} + +unit:: + sh ${top_srcdir}/unit/unittest.sh + +clean distclean:: + rm -f ${TARGETS} + rm -f atf.out diff --git a/lib/irs/tests/resconf_test.c b/lib/irs/tests/resconf_test.c new file mode 100644 index 0000000000..21bc6494be --- /dev/null +++ b/lib/irs/tests/resconf_test.c @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2014, 2016 Internet Systems Consortium, Inc. ("ISC") + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +static isc_mem_t *mctx = NULL; + +static void +setup_test() { + isc_result_t result; + + result = isc_mem_create(0, 0, &mctx); + ATF_REQUIRE_EQ(result, ISC_R_SUCCESS); + + /* + * atf-run changes us to a /tmp directory, so tests + * that access test data files must first chdir to the proper + * location. + */ + ATF_REQUIRE(chdir(TESTS) != -1); +} + +ATF_TC(irs_resconf_load); +ATF_TC_HEAD(irs_resconf_load, tc) { + atf_tc_set_md_var(tc, "descr", "irs_resconf_load"); +} +ATF_TC_BODY(irs_resconf_load, tc) { + isc_result_t result; + irs_resconf_t *resconf = NULL; + unsigned int i; + struct { + const char *file; + isc_result_t loadres; + isc_result_t (*check)(irs_resconf_t *resconf); + isc_result_t checkres; + } tests[] = { + { + "testdata/sortlist-v4.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/domain.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/nameserver-v4.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/nameserver-v6.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options-debug.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options-ndots.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options-timeout.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options-unknown.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/options.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/port.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/resolv.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/search.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/sortlist-v4.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/timeout.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + }, { + "testdata/unknown.conf", ISC_R_SUCCESS, + NULL, ISC_R_SUCCESS + } + + }; + + UNUSED(tc); + + setup_test(); + + for (i = 0; i < sizeof(tests)/sizeof(tests[1]); i++) { + result = irs_resconf_load(mctx, tests[i].file, &resconf); + ATF_CHECK_EQ_MSG(result, tests[i].loadres, "%s", tests[i].file); + if (result == ISC_R_SUCCESS) + ATF_CHECK_MSG(resconf != NULL, "%s", tests[i].file); + else + ATF_CHECK_MSG(resconf == NULL, "%s", tests[i].file); + if (resconf != NULL && tests[i].check != NULL) { + result = (tests[i].check)(resconf); + ATF_CHECK_EQ_MSG(result, tests[i].checkres, "%s", + tests[i].file); + } + if (resconf != NULL) + irs_resconf_destroy(&resconf); + } + + isc_mem_detach(&mctx); +} + +/* + * Main + */ +ATF_TP_ADD_TCS(tp) { + ATF_TP_ADD_TC(tp, irs_resconf_load); + return (atf_no_error()); +} diff --git a/lib/irs/tests/testdata/domain.conf b/lib/irs/tests/testdata/domain.conf new file mode 100644 index 0000000000..6c458e6828 --- /dev/null +++ b/lib/irs/tests/testdata/domain.conf @@ -0,0 +1 @@ +domain example.com diff --git a/lib/irs/tests/testdata/nameserver-v4.conf b/lib/irs/tests/testdata/nameserver-v4.conf new file mode 100644 index 0000000000..84fcf26ee5 --- /dev/null +++ b/lib/irs/tests/testdata/nameserver-v4.conf @@ -0,0 +1 @@ +nameserver 10.0.0.1 diff --git a/lib/irs/tests/testdata/nameserver-v6.conf b/lib/irs/tests/testdata/nameserver-v6.conf new file mode 100644 index 0000000000..cac6273623 --- /dev/null +++ b/lib/irs/tests/testdata/nameserver-v6.conf @@ -0,0 +1 @@ +nameserver 2001:DB8::1 diff --git a/lib/irs/tests/testdata/options-debug.conf b/lib/irs/tests/testdata/options-debug.conf new file mode 100644 index 0000000000..9c311372b1 --- /dev/null +++ b/lib/irs/tests/testdata/options-debug.conf @@ -0,0 +1 @@ +options debug diff --git a/lib/irs/tests/testdata/options-ndots.conf b/lib/irs/tests/testdata/options-ndots.conf new file mode 100644 index 0000000000..f3a23e296b --- /dev/null +++ b/lib/irs/tests/testdata/options-ndots.conf @@ -0,0 +1 @@ +option ndots:2 diff --git a/lib/irs/tests/testdata/options-timeout.conf b/lib/irs/tests/testdata/options-timeout.conf new file mode 100644 index 0000000000..6914e324da --- /dev/null +++ b/lib/irs/tests/testdata/options-timeout.conf @@ -0,0 +1 @@ +options timeout:1 diff --git a/lib/irs/tests/testdata/options-unknown.conf b/lib/irs/tests/testdata/options-unknown.conf new file mode 100644 index 0000000000..d9a095acc6 --- /dev/null +++ b/lib/irs/tests/testdata/options-unknown.conf @@ -0,0 +1 @@ +options unknown diff --git a/lib/irs/tests/testdata/options.conf b/lib/irs/tests/testdata/options.conf new file mode 100644 index 0000000000..8d31c27807 --- /dev/null +++ b/lib/irs/tests/testdata/options.conf @@ -0,0 +1 @@ +options unknown debug timeout:1 ndots:2 diff --git a/lib/irs/tests/testdata/port.conf b/lib/irs/tests/testdata/port.conf new file mode 100644 index 0000000000..5333a58caf --- /dev/null +++ b/lib/irs/tests/testdata/port.conf @@ -0,0 +1 @@ +port 5300 diff --git a/lib/irs/tests/testdata/resolv.conf b/lib/irs/tests/testdata/resolv.conf new file mode 100644 index 0000000000..916634b8bf --- /dev/null +++ b/lib/irs/tests/testdata/resolv.conf @@ -0,0 +1,8 @@ +port 5300 +nameserver 10.0.0.1 +nameserver 2001:DB8::1 +search example.com example.net +sortlist 130.155.160.0/255.255.240.0 130.155.0.0 +timeout 10 +unknown directive +options unknown debug timeout:1 ndots:2 diff --git a/lib/irs/tests/testdata/search.conf b/lib/irs/tests/testdata/search.conf new file mode 100644 index 0000000000..464390cbaf --- /dev/null +++ b/lib/irs/tests/testdata/search.conf @@ -0,0 +1 @@ +search example.com example.net diff --git a/lib/irs/tests/testdata/sortlist-v4.conf b/lib/irs/tests/testdata/sortlist-v4.conf new file mode 100644 index 0000000000..5cb283f442 --- /dev/null +++ b/lib/irs/tests/testdata/sortlist-v4.conf @@ -0,0 +1 @@ +sortlist 130.155.160.0/255.255.240.0 130.155.0.0 diff --git a/lib/irs/tests/testdata/timeout.conf b/lib/irs/tests/testdata/timeout.conf new file mode 100644 index 0000000000..6655b89321 --- /dev/null +++ b/lib/irs/tests/testdata/timeout.conf @@ -0,0 +1 @@ +timeout 10 diff --git a/lib/irs/tests/testdata/unknown.conf b/lib/irs/tests/testdata/unknown.conf new file mode 100644 index 0000000000..27ceb3e0e7 --- /dev/null +++ b/lib/irs/tests/testdata/unknown.conf @@ -0,0 +1 @@ +unknown directive diff --git a/lib/isc/include/isc/sockaddr.h b/lib/isc/include/isc/sockaddr.h index b9f751955a..18cd06a048 100644 --- a/lib/isc/include/isc/sockaddr.h +++ b/lib/isc/include/isc/sockaddr.h @@ -34,8 +34,6 @@ struct isc_sockaddr { ISC_LINK(struct isc_sockaddr) link; }; -typedef ISC_LIST(struct isc_sockaddr) isc_sockaddrlist_t; - #define ISC_SOCKADDR_CMPADDR 0x0001 /*%< compare the address * sin_addr/sin6_addr */ #define ISC_SOCKADDR_CMPPORT 0x0002 /*%< compare the port diff --git a/lib/isc/include/isc/types.h b/lib/isc/include/isc/types.h index 4372202c34..6679bbc43c 100644 --- a/lib/isc/include/isc/types.h +++ b/lib/isc/include/isc/types.h @@ -75,6 +75,7 @@ typedef isc_uint64_t isc_resourcevalue_t; /*%< Resource Value */ typedef unsigned int isc_result_t; /*%< Result */ typedef struct isc_rwlock isc_rwlock_t; /*%< Read Write Lock */ typedef struct isc_sockaddr isc_sockaddr_t; /*%< Socket Address */ +typedef ISC_LIST(isc_sockaddr_t) isc_sockaddrlist_t; /*%< Socket Address List */ typedef struct isc_socket isc_socket_t; /*%< Socket */ typedef struct isc_socketevent isc_socketevent_t; /*%< Socket Event */ typedef struct isc_socketmgr isc_socketmgr_t; /*%< Socket Manager */