4207. [bug] Handle class mismatches with raw zone files.

[RT #40746]
This commit is contained in:
Mark Andrews 2015-09-16 10:43:22 +10:00
parent 1eec6885ab
commit 0f2ecf4b5c
7 changed files with 34 additions and 4 deletions

View file

@ -1,3 +1,6 @@
4207. [bug] Handle class mismatches with raw zone files.
[RT #40746]
4206. [bug] contrib: fixed a possible NULL dereference in
DLZ wildcard module. [RT #40745]

View file

@ -133,5 +133,13 @@ n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:checking that raw zone with bad class is handled ($n)"
ret=0
$CHECKZONE -f raw example zones/bad-badclass.raw > test.out.$n 2>&1 && ret=1
grep "failed: bad class" test.out.$n >/dev/null || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:exit status: $status"
exit $status

View file

@ -0,0 +1 @@
*.raw -text

Binary file not shown.

View file

@ -2385,6 +2385,10 @@ load_raw(dns_loadctx_t *lctx) {
/* Construct RRset headers */
dns_rdatalist_init(&rdatalist);
rdatalist.rdclass = isc_buffer_getuint16(&target);
if (lctx->zclass != rdatalist.rdclass) {
result = DNS_R_BADCLASS;
goto cleanup;
}
rdatalist.type = isc_buffer_getuint16(&target);
rdatalist.covers = isc_buffer_getuint16(&target);
rdatalist.ttl = isc_buffer_getuint32(&target);

View file

@ -7118,13 +7118,14 @@ loading_addrdataset(void *arg, dns_name_t *name, dns_rdataset_t *rdataset) {
isc_region_t region;
rdatasetheader_t *newheader;
REQUIRE(rdataset->rdclass == rbtdb->common.rdclass);
/*
* This routine does no node locking. See comments in
* 'load' below for more information on loading and
* locking.
*/
/*
* SOA records are only allowed at top of zone.
*/

View file

@ -292,6 +292,9 @@ axfr_putdata(dns_xfrin_ctx_t *xfr, dns_diffop_t op,
dns_difftuple_t *tuple = NULL;
if (rdata->rdclass != xfr->rdclass)
return(DNS_R_BADCLASS);
CHECK(dns_zone_checknames(xfr->zone, name, rdata));
CHECK(dns_difftuple_create(xfr->diff.mctx, op,
name, ttl, rdata, &tuple));
@ -376,8 +379,11 @@ ixfr_putdata(dns_xfrin_ctx_t *xfr, dns_diffop_t op,
dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata)
{
isc_result_t result;
dns_difftuple_t *tuple = NULL;
if (rdata->rdclass != xfr->rdclass)
return(DNS_R_BADCLASS);
if (op == DNS_DIFFOP_ADD)
CHECK(dns_zone_checknames(xfr->zone, name, rdata));
CHECK(dns_difftuple_create(xfr->diff.mctx, op,
@ -1246,10 +1252,17 @@ xfrin_recv_done(isc_task_t *task, isc_event_t *ev) {
dns_result_totext(result));
if (result != ISC_R_SUCCESS || msg->rcode != dns_rcode_noerror ||
msg->opcode != dns_opcode_query ||msg->rdclass != xfr->rdclass ||
(xfr->checkid && msg->id != xfr->id)) {
if (result == ISC_R_SUCCESS)
if (result == ISC_R_SUCCESS && msg->rcode != dns_rcode_noerror)
result = ISC_RESULTCLASS_DNSRCODE + msg->rcode; /*XXX*/
if (result == ISC_R_SUCCESS || result == DNS_R_NOERROR)
else if (result == ISC_R_SUCCESS &&
msg->opcode != dns_opcode_query)
result = DNS_R_UNEXPECTEDOPCODE;
else if (result == ISC_R_SUCCESS &&
msg->rdclass != xfr->rdclass)
result = DNS_R_BADCLASS;
else if (result == ISC_R_SUCCESS || result == DNS_R_NOERROR)
result = DNS_R_UNEXPECTEDID;
if (xfr->reqtype == dns_rdatatype_axfr ||
xfr->reqtype == dns_rdatatype_soa)