3364. [security] Named could die on specially crafted record.

[RT #30416]
This commit is contained in:
Mark Andrews
2012-08-16 09:42:14 +10:00
parent b8493d3292
commit 1bbd36c4db
10 changed files with 3399 additions and 12 deletions

View File

@@ -39,15 +39,16 @@ LIBS = @LIBS@ @ATFLIBS@
OBJS = dnstest.@O@
SRCS = dnstest.c master_test.c dbiterator_test.c time_test.c \
private_test.c update_test.c zonemgr_test.c zt_test.c \
dbdiff_test.c nsec3_test.c dispatch_test.c rdatasetstats_test.c \
rbt_test.c rdataset_test.c
dbdiff_test.c nsec3_test.c dispatch_test.c rbt_test.c \
rdata_test.c rdataset_test.c rdatasetstats_test.c
SUBDIRS =
TARGETS = master_test@EXEEXT@ dbiterator_test@EXEEXT@ time_test@EXEEXT@ \
private_test@EXEEXT@ update_test@EXEEXT@ zonemgr_test@EXEEXT@ \
zt_test@EXEEXT@ dbversion_test@EXEEXT@ dbdiff_test@EXEEXT@ \
nsec3_test@EXEEXT@ dispatch_test@EXEEXT@ rdatasetstats_test@EXEEXT@ \
rbt_test@EXEEXT@ rdataset_test@EXEEXT@
nsec3_test@EXEEXT@ dispatch_test@EXEEXT@ rbt_test@EXEEXT@ \
rdata_test@EXEEXT@ rdataset_test@EXEEXT@ \
rdatasetstats_test@EXEEXT@
@BIND9_MAKE_RULES@
@@ -127,6 +128,10 @@ rbt_test@EXEEXT@: rbt_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
rbt_test.@O@ dnstest.@O@ ${DNSLIBS} \
${ISCLIBS} ${LIBS}
rdata_test@EXEEXT@: rdata_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
rdata_test.@O@ ${DNSLIBS} ${ISCLIBS} ${LIBS}
unit::
sh ${top_srcdir}/unit/unittest.sh

View File

@@ -44,7 +44,7 @@
*/
#define BUFLEN 255
#define BIGBUFLEN (64 * 1024)
#define BIGBUFLEN (70 * 1024)
#define TEST_ORIGIN "test"
static dns_masterrawheader_t header;
@@ -251,6 +251,51 @@ ATF_TC_BODY(badclass, tc) {
dns_test_end();
}
/* Too big rdata test */
ATF_TC(toobig);
ATF_TC_HEAD(toobig, tc) {
atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns "
"ISC_R_NOSPACE when record is too big");
}
ATF_TC_BODY(toobig, tc) {
isc_result_t result;
UNUSED(tc);
result = dns_test_begin(NULL, ISC_FALSE);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
setup_master();
result = test_master("testdata/master/master15.data",
dns_masterformat_text);
ATF_REQUIRE_EQ(result, ISC_R_NOSPACE);
dns_test_end();
}
/* Maximum rdata test */
ATF_TC(maxrdata);
ATF_TC_HEAD(maxrdata, tc) {
atf_tc_set_md_var(tc, "descr", "dns_master_loadfile() returns "
"ISC_R_SUCCESS when record is maximum "
"size");
}
ATF_TC_BODY(maxrdata, tc) {
isc_result_t result;
UNUSED(tc);
result = dns_test_begin(NULL, ISC_FALSE);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
setup_master();
result = test_master("testdata/master/master16.data",
dns_masterformat_text);
ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
dns_test_end();
}
/* DNSKEY test */
ATF_TC(dnskey);
ATF_TC_HEAD(dnskey, tc) {
@@ -596,6 +641,8 @@ ATF_TP_ADD_TCS(tp) {
ATF_TP_ADD_TC(tp, totext);
ATF_TP_ADD_TC(tp, loadraw);
ATF_TP_ADD_TC(tp, dumpraw);
ATF_TP_ADD_TC(tp, toobig);
ATF_TP_ADD_TC(tp, maxrdata);
return (atf_no_error());
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (C) 2012 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$ */
/*! \file */
#include <config.h>
#include <atf-c.h>
#include <unistd.h>
#include <isc/types.h>
#include <dns/rdata.h>
#include "dnstest.h"
/*
* Individual unit tests
*/
/* Successful load test */
ATF_TC(hip);
ATF_TC_HEAD(hip, tc) {
atf_tc_set_md_var(tc, "descr", "that a oversized HIP record will "
"be rejected");
}
ATF_TC_BODY(hip, tc) {
unsigned char hipwire[DNS_RDATA_MAXLENGTH] = {
0x01, 0x00, 0x00, 0x01, 0x00, 0x00,
0x04, 0x41, 0x42, 0x43, 0x44, 0x00 };
unsigned char buf[1024*1024];
isc_buffer_t source, target;
dns_rdata_t rdata;
dns_decompress_t dctx;
isc_result_t result;
size_t i;
UNUSED(tc);
/*
* Fill the rest of input buffer with compression pointers.
*/
for (i = 12; i < sizeof(hipwire) - 2; i += 2) {
hipwire[i] = 0xc0;
hipwire[i+1] = 0x06;
}
isc_buffer_init(&source, hipwire, sizeof(hipwire));
isc_buffer_add(&source, sizeof(hipwire));
isc_buffer_setactive(&source, i);
isc_buffer_init(&target, buf, sizeof(buf));
dns_rdata_init(&rdata);
dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_ANY);
result = dns_rdata_fromwire(&rdata, dns_rdataclass_in,
dns_rdatatype_hip, &source, &dctx,
0, &target);
dns_decompress_invalidate(&dctx);
ATF_REQUIRE_EQ(result, DNS_R_FORMERR);
}
/*
* Main
*/
ATF_TP_ADD_TCS(tp) {
ATF_TP_ADD_TC(tp, hip);
return (atf_no_error());
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff