mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 15:45:25 +00:00
2890. [bug] Handle the introduction of new trusted-keys and
DS, DLV RRsets better. [RT #21097]
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,3 +1,6 @@
|
|||||||
|
2890. [bug] Handle the introduction of new trusted-keys and
|
||||||
|
DS, DLV RRsets better. [RT #21097]
|
||||||
|
|
||||||
2889. [bug] Elements of the grammar where not properly reported.
|
2889. [bug] Elements of the grammar where not properly reported.
|
||||||
[RT #21046]
|
[RT #21046]
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: ncache.h,v 1.27 2009/12/30 23:49:14 tbox Exp $ */
|
/* $Id: ncache.h,v 1.28 2010/05/14 00:13:43 marka Exp $ */
|
||||||
|
|
||||||
#ifndef DNS_NCACHE_H
|
#ifndef DNS_NCACHE_H
|
||||||
#define DNS_NCACHE_H 1
|
#define DNS_NCACHE_H 1
|
||||||
@@ -161,6 +161,13 @@ dns_ncache_getrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dns_ncache_getsigrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
|
||||||
|
dns_rdatatype_t covers, dns_rdataset_t *rdataset);
|
||||||
|
/*%<
|
||||||
|
* Similar to dns_ncache_getrdataset() but get the rrsig that matches.
|
||||||
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_ncache_current(dns_rdataset_t *ncacherdataset, dns_name_t *found,
|
dns_ncache_current(dns_rdataset_t *ncacherdataset, dns_name_t *found,
|
||||||
dns_rdataset_t *rdataset);
|
dns_rdataset_t *rdataset);
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: types.h,v 1.139 2009/12/30 08:02:23 jinmei Exp $ */
|
/* $Id: types.h,v 1.140 2010/05/14 00:13:43 marka Exp $ */
|
||||||
|
|
||||||
#ifndef DNS_TYPES_H
|
#ifndef DNS_TYPES_H
|
||||||
#define DNS_TYPES_H 1
|
#define DNS_TYPES_H 1
|
||||||
@@ -321,6 +321,7 @@ enum {
|
|||||||
#define DNS_TRUST_ADDITIONAL(x) ((x) == dns_trust_additional || \
|
#define DNS_TRUST_ADDITIONAL(x) ((x) == dns_trust_additional || \
|
||||||
(x) == dns_trust_pending_additional)
|
(x) == dns_trust_pending_additional)
|
||||||
#define DNS_TRUST_GLUE(x) ((x) == dns_trust_glue)
|
#define DNS_TRUST_GLUE(x) ((x) == dns_trust_glue)
|
||||||
|
#define DNS_TRUST_ANSWER(x) ((x) == dns_trust_answer)
|
||||||
|
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
|
142
lib/dns/ncache.c
142
lib/dns/ncache.c
@@ -15,7 +15,7 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: ncache.c,v 1.45 2010/02/25 05:08:01 tbox Exp $ */
|
/* $Id: ncache.c,v 1.46 2010/05/14 00:13:43 marka Exp $ */
|
||||||
|
|
||||||
/*! \file */
|
/*! \file */
|
||||||
|
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
*
|
*
|
||||||
* owner name
|
* owner name
|
||||||
* type
|
* type
|
||||||
|
* trust
|
||||||
* rdata count
|
* rdata count
|
||||||
* rdata length These two occur 'rdata count'
|
* rdata length These two occur 'rdata count'
|
||||||
* rdata times.
|
* rdata times.
|
||||||
@@ -189,6 +190,8 @@ dns_ncache_addoptout(dns_message_t *message, dns_db_t *cache,
|
|||||||
return (ISC_R_NOSPACE);
|
return (ISC_R_NOSPACE);
|
||||||
isc_buffer_putuint16(&buffer,
|
isc_buffer_putuint16(&buffer,
|
||||||
rdataset->type);
|
rdataset->type);
|
||||||
|
isc_buffer_putuint8(&buffer,
|
||||||
|
rdataset->trust);
|
||||||
/*
|
/*
|
||||||
* Copy the rdataset into the buffer.
|
* Copy the rdataset into the buffer.
|
||||||
*/
|
*/
|
||||||
@@ -335,8 +338,9 @@ dns_ncache_towire(dns_rdataset_t *rdataset, dns_compress_t *cctx,
|
|||||||
isc_buffer_forward(&source, name.length);
|
isc_buffer_forward(&source, name.length);
|
||||||
remaining.length -= name.length;
|
remaining.length -= name.length;
|
||||||
|
|
||||||
INSIST(remaining.length >= 4);
|
INSIST(remaining.length >= 5);
|
||||||
type = isc_buffer_getuint16(&source);
|
type = isc_buffer_getuint16(&source);
|
||||||
|
isc_buffer_forward(&source, 1);
|
||||||
rcount = isc_buffer_getuint16(&source);
|
rcount = isc_buffer_getuint16(&source);
|
||||||
|
|
||||||
for (i = 0; i < rcount; i++) {
|
for (i = 0; i < rcount; i++) {
|
||||||
@@ -506,6 +510,13 @@ rdataset_count(dns_rdataset_t *rdataset) {
|
|||||||
return (count);
|
return (count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rdataset_settrust(dns_rdataset_t *rdataset, dns_trust_t trust) {
|
||||||
|
unsigned char *raw = rdataset->private3;
|
||||||
|
|
||||||
|
raw[-1] = trust;
|
||||||
|
}
|
||||||
|
|
||||||
static dns_rdatasetmethods_t rdataset_methods = {
|
static dns_rdatasetmethods_t rdataset_methods = {
|
||||||
rdataset_disassociate,
|
rdataset_disassociate,
|
||||||
rdataset_first,
|
rdataset_first,
|
||||||
@@ -520,7 +531,7 @@ static dns_rdatasetmethods_t rdataset_methods = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
rdataset_settrust,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -534,6 +545,8 @@ dns_ncache_getrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
|
|||||||
isc_buffer_t source;
|
isc_buffer_t source;
|
||||||
dns_name_t tname;
|
dns_name_t tname;
|
||||||
dns_rdatatype_t ttype;
|
dns_rdatatype_t ttype;
|
||||||
|
dns_trust_t trust = dns_trust_none;
|
||||||
|
dns_rdataset_t clone;
|
||||||
|
|
||||||
REQUIRE(ncacherdataset != NULL);
|
REQUIRE(ncacherdataset != NULL);
|
||||||
REQUIRE(ncacherdataset->type == 0);
|
REQUIRE(ncacherdataset->type == 0);
|
||||||
@@ -541,9 +554,11 @@ dns_ncache_getrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
|
|||||||
REQUIRE(!dns_rdataset_isassociated(rdataset));
|
REQUIRE(!dns_rdataset_isassociated(rdataset));
|
||||||
REQUIRE(type != dns_rdatatype_rrsig);
|
REQUIRE(type != dns_rdatatype_rrsig);
|
||||||
|
|
||||||
result = dns_rdataset_first(ncacherdataset);
|
dns_rdataset_init(&clone);
|
||||||
|
dns_rdataset_clone(ncacherdataset, &clone);
|
||||||
|
result = dns_rdataset_first(&clone);
|
||||||
while (result == ISC_R_SUCCESS) {
|
while (result == ISC_R_SUCCESS) {
|
||||||
dns_rdataset_current(ncacherdataset, &rdata);
|
dns_rdataset_current(&clone, &rdata);
|
||||||
isc_buffer_init(&source, rdata.data, rdata.length);
|
isc_buffer_init(&source, rdata.data, rdata.length);
|
||||||
isc_buffer_add(&source, rdata.length);
|
isc_buffer_add(&source, rdata.length);
|
||||||
dns_name_init(&tname, NULL);
|
dns_name_init(&tname, NULL);
|
||||||
@@ -553,16 +568,19 @@ dns_ncache_getrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
|
|||||||
isc_buffer_forward(&source, tname.length);
|
isc_buffer_forward(&source, tname.length);
|
||||||
remaining.length -= tname.length;
|
remaining.length -= tname.length;
|
||||||
|
|
||||||
INSIST(remaining.length >= 4);
|
INSIST(remaining.length >= 3);
|
||||||
ttype = isc_buffer_getuint16(&source);
|
ttype = isc_buffer_getuint16(&source);
|
||||||
|
|
||||||
if (ttype == type && dns_name_equal(&tname, name)) {
|
if (ttype == type && dns_name_equal(&tname, name)) {
|
||||||
|
trust = isc_buffer_getuint8(&source);
|
||||||
|
INSIST(trust <= dns_trust_ultimate);
|
||||||
isc_buffer_remainingregion(&source, &remaining);
|
isc_buffer_remainingregion(&source, &remaining);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result = dns_rdataset_next(ncacherdataset);
|
result = dns_rdataset_next(&clone);
|
||||||
dns_rdata_reset(&rdata);
|
dns_rdata_reset(&rdata);
|
||||||
}
|
}
|
||||||
|
dns_rdataset_disassociate(&clone);
|
||||||
if (result == ISC_R_NOMORE)
|
if (result == ISC_R_NOMORE)
|
||||||
return (ISC_R_NOTFOUND);
|
return (ISC_R_NOTFOUND);
|
||||||
if (result != ISC_R_SUCCESS)
|
if (result != ISC_R_SUCCESS)
|
||||||
@@ -575,7 +593,108 @@ dns_ncache_getrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
|
|||||||
rdataset->type = type;
|
rdataset->type = type;
|
||||||
rdataset->covers = 0;
|
rdataset->covers = 0;
|
||||||
rdataset->ttl = ncacherdataset->ttl;
|
rdataset->ttl = ncacherdataset->ttl;
|
||||||
rdataset->trust = ncacherdataset->trust;
|
rdataset->trust = trust;
|
||||||
|
rdataset->private1 = NULL;
|
||||||
|
rdataset->private2 = NULL;
|
||||||
|
|
||||||
|
rdataset->private3 = remaining.base;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reset iterator state.
|
||||||
|
*/
|
||||||
|
rdataset->privateuint4 = 0;
|
||||||
|
rdataset->private5 = NULL;
|
||||||
|
rdataset->private6 = NULL;
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
isc_result_t
|
||||||
|
dns_ncache_getsigrdataset(dns_rdataset_t *ncacherdataset, dns_name_t *name,
|
||||||
|
dns_rdatatype_t covers, dns_rdataset_t *rdataset)
|
||||||
|
{
|
||||||
|
dns_name_t tname;
|
||||||
|
dns_rdata_rrsig_t rrsig;
|
||||||
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||||
|
dns_rdataset_t clone;
|
||||||
|
dns_rdatatype_t type;
|
||||||
|
dns_trust_t trust = dns_trust_none;
|
||||||
|
isc_buffer_t source;
|
||||||
|
isc_region_t remaining, sigregion;
|
||||||
|
isc_result_t result;
|
||||||
|
unsigned char *raw;
|
||||||
|
unsigned int count;
|
||||||
|
|
||||||
|
REQUIRE(ncacherdataset != NULL);
|
||||||
|
REQUIRE(ncacherdataset->type == 0);
|
||||||
|
REQUIRE(name != NULL);
|
||||||
|
REQUIRE(!dns_rdataset_isassociated(rdataset));
|
||||||
|
|
||||||
|
dns_rdataset_init(&clone);
|
||||||
|
dns_rdataset_clone(ncacherdataset, &clone);
|
||||||
|
result = dns_rdataset_first(&clone);
|
||||||
|
while (result == ISC_R_SUCCESS) {
|
||||||
|
dns_rdataset_current(&clone, &rdata);
|
||||||
|
isc_buffer_init(&source, rdata.data, rdata.length);
|
||||||
|
isc_buffer_add(&source, rdata.length);
|
||||||
|
dns_name_init(&tname, NULL);
|
||||||
|
isc_buffer_remainingregion(&source, &remaining);
|
||||||
|
dns_name_fromregion(&tname, &remaining);
|
||||||
|
INSIST(remaining.length >= tname.length);
|
||||||
|
isc_buffer_forward(&source, tname.length);
|
||||||
|
remaining.length -= tname.length;
|
||||||
|
remaining.base += tname.length;
|
||||||
|
|
||||||
|
INSIST(remaining.length >= 2);
|
||||||
|
type = isc_buffer_getuint16(&source);
|
||||||
|
remaining.length -= 2;
|
||||||
|
remaining.base += 2;
|
||||||
|
|
||||||
|
if (type != dns_rdatatype_rrsig ||
|
||||||
|
!dns_name_equal(&tname, name)) {
|
||||||
|
result = dns_rdataset_next(&clone);
|
||||||
|
dns_rdata_reset(&rdata);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
INSIST(remaining.length >= 1);
|
||||||
|
trust = isc_buffer_getuint8(&source);
|
||||||
|
INSIST(trust <= dns_trust_ultimate);
|
||||||
|
remaining.length -= 1;
|
||||||
|
remaining.base += 1;
|
||||||
|
|
||||||
|
raw = remaining.base;
|
||||||
|
count = raw[0] * 256 + raw[1];
|
||||||
|
INSIST(count > 0);
|
||||||
|
raw += 2;
|
||||||
|
sigregion.length = raw[0] * 256 + raw[1];
|
||||||
|
raw += 2;
|
||||||
|
sigregion.base = raw;
|
||||||
|
dns_rdata_reset(&rdata);
|
||||||
|
dns_rdata_fromregion(&rdata, rdataset->rdclass,
|
||||||
|
dns_rdatatype_rrsig, &sigregion);
|
||||||
|
(void)dns_rdata_tostruct(&rdata, &rrsig, NULL);
|
||||||
|
if (rrsig.covered == covers) {
|
||||||
|
isc_buffer_remainingregion(&source, &remaining);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = dns_rdataset_next(&clone);
|
||||||
|
dns_rdata_reset(&rdata);
|
||||||
|
}
|
||||||
|
dns_rdataset_disassociate(&clone);
|
||||||
|
if (result == ISC_R_NOMORE)
|
||||||
|
return (ISC_R_NOTFOUND);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
|
||||||
|
INSIST(remaining.length != 0);
|
||||||
|
|
||||||
|
rdataset->methods = &rdataset_methods;
|
||||||
|
rdataset->rdclass = ncacherdataset->rdclass;
|
||||||
|
rdataset->type = dns_rdatatype_rrsig;
|
||||||
|
rdataset->covers = covers;
|
||||||
|
rdataset->ttl = ncacherdataset->ttl;
|
||||||
|
rdataset->trust = trust;
|
||||||
rdataset->private1 = NULL;
|
rdataset->private1 = NULL;
|
||||||
rdataset->private2 = NULL;
|
rdataset->private2 = NULL;
|
||||||
|
|
||||||
@@ -595,6 +714,7 @@ dns_ncache_current(dns_rdataset_t *ncacherdataset, dns_name_t *found,
|
|||||||
dns_rdataset_t *rdataset)
|
dns_rdataset_t *rdataset)
|
||||||
{
|
{
|
||||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||||
|
dns_trust_t trust;
|
||||||
isc_region_t remaining, sigregion;
|
isc_region_t remaining, sigregion;
|
||||||
isc_buffer_t source;
|
isc_buffer_t source;
|
||||||
dns_name_t tname;
|
dns_name_t tname;
|
||||||
@@ -619,8 +739,10 @@ dns_ncache_current(dns_rdataset_t *ncacherdataset, dns_name_t *found,
|
|||||||
isc_buffer_forward(&source, found->length);
|
isc_buffer_forward(&source, found->length);
|
||||||
remaining.length -= found->length;
|
remaining.length -= found->length;
|
||||||
|
|
||||||
INSIST(remaining.length >= 4);
|
INSIST(remaining.length >= 5);
|
||||||
type = isc_buffer_getuint16(&source);
|
type = isc_buffer_getuint16(&source);
|
||||||
|
trust = isc_buffer_getuint8(&source);
|
||||||
|
INSIST(trust <= dns_trust_ultimate);
|
||||||
isc_buffer_remainingregion(&source, &remaining);
|
isc_buffer_remainingregion(&source, &remaining);
|
||||||
|
|
||||||
rdataset->methods = &rdataset_methods;
|
rdataset->methods = &rdataset_methods;
|
||||||
@@ -645,7 +767,7 @@ dns_ncache_current(dns_rdataset_t *ncacherdataset, dns_name_t *found,
|
|||||||
} else
|
} else
|
||||||
rdataset->covers = 0;
|
rdataset->covers = 0;
|
||||||
rdataset->ttl = ncacherdataset->ttl;
|
rdataset->ttl = ncacherdataset->ttl;
|
||||||
rdataset->trust = ncacherdataset->trust;
|
rdataset->trust = trust;
|
||||||
rdataset->private1 = NULL;
|
rdataset->private1 = NULL;
|
||||||
rdataset->private2 = NULL;
|
rdataset->private2 = NULL;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user