mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
4492. [bug] irs_resconf_load failed to initialise sortlistnxt
causing bad writes if resolv.conf contained a sortlist directive. [RT #43459]
This commit is contained in:
4
CHANGES
4
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]
|
||||
|
||||
|
3
configure
vendored
3
configure
vendored
@@ -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" ;;
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
5
lib/irs/Atffile
Normal file
5
lib/irs/Atffile
Normal file
@@ -0,0 +1,5 @@
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
prop: test-suite = bind9
|
||||
|
||||
tp: tests
|
@@ -38,6 +38,7 @@ SRCS = context.c \
|
||||
LIBS = @LIBS@
|
||||
|
||||
SUBDIRS = include
|
||||
TESTDIRS = @UNITTESTS@
|
||||
TARGETS = timestamp
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
@@ -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;
|
||||
|
5
lib/irs/tests/Atffile
Normal file
5
lib/irs/tests/Atffile
Normal file
@@ -0,0 +1,5 @@
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
prop: test-suite = bind9
|
||||
|
||||
tp-glob: *_test
|
52
lib/irs/tests/Makefile.in
Normal file
52
lib/irs/tests/Makefile.in
Normal file
@@ -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
|
133
lib/irs/tests/resconf_test.c
Normal file
133
lib/irs/tests/resconf_test.c
Normal file
@@ -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 <config.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/mem.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <irs/types.h>
|
||||
#include <irs/resconf.h>
|
||||
|
||||
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());
|
||||
}
|
1
lib/irs/tests/testdata/domain.conf
vendored
Normal file
1
lib/irs/tests/testdata/domain.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
domain example.com
|
1
lib/irs/tests/testdata/nameserver-v4.conf
vendored
Normal file
1
lib/irs/tests/testdata/nameserver-v4.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
nameserver 10.0.0.1
|
1
lib/irs/tests/testdata/nameserver-v6.conf
vendored
Normal file
1
lib/irs/tests/testdata/nameserver-v6.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
nameserver 2001:DB8::1
|
1
lib/irs/tests/testdata/options-debug.conf
vendored
Normal file
1
lib/irs/tests/testdata/options-debug.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
options debug
|
1
lib/irs/tests/testdata/options-ndots.conf
vendored
Normal file
1
lib/irs/tests/testdata/options-ndots.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
option ndots:2
|
1
lib/irs/tests/testdata/options-timeout.conf
vendored
Normal file
1
lib/irs/tests/testdata/options-timeout.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
options timeout:1
|
1
lib/irs/tests/testdata/options-unknown.conf
vendored
Normal file
1
lib/irs/tests/testdata/options-unknown.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
options unknown
|
1
lib/irs/tests/testdata/options.conf
vendored
Normal file
1
lib/irs/tests/testdata/options.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
options unknown debug timeout:1 ndots:2
|
1
lib/irs/tests/testdata/port.conf
vendored
Normal file
1
lib/irs/tests/testdata/port.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
port 5300
|
8
lib/irs/tests/testdata/resolv.conf
vendored
Normal file
8
lib/irs/tests/testdata/resolv.conf
vendored
Normal file
@@ -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
|
1
lib/irs/tests/testdata/search.conf
vendored
Normal file
1
lib/irs/tests/testdata/search.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
search example.com example.net
|
1
lib/irs/tests/testdata/sortlist-v4.conf
vendored
Normal file
1
lib/irs/tests/testdata/sortlist-v4.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
sortlist 130.155.160.0/255.255.240.0 130.155.0.0
|
1
lib/irs/tests/testdata/timeout.conf
vendored
Normal file
1
lib/irs/tests/testdata/timeout.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
timeout 10
|
1
lib/irs/tests/testdata/unknown.conf
vendored
Normal file
1
lib/irs/tests/testdata/unknown.conf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
unknown directive
|
@@ -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
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user