mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
3364. [security] Named could die on specially crafted record.
[RT #30416]
This commit is contained in:
86
lib/dns/tests/rdata_test.c
Normal file
86
lib/dns/tests/rdata_test.c
Normal 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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user