mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
fix and simplify dns_rdataset_equal() and _equalx()
if both rdataslabs being compared have zero length, return true. also, since these functions are only ever called on slabheaders with sizeof(dns_slabheader_t) as the reserve length, we can simplify the API: remove the reservelen argument, and pass the slabs as type dns_slabheader_t * instead of unsigned char *.
This commit is contained in:
@@ -251,8 +251,7 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
dns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2,
|
dns_rdataslab_equal(dns_slabheader_t *slab1, dns_slabheader_t *slab2);
|
||||||
unsigned int reservelen);
|
|
||||||
/*%<
|
/*%<
|
||||||
* Compare two rdataslabs for equality. This does _not_ do a full
|
* Compare two rdataslabs for equality. This does _not_ do a full
|
||||||
* DNSSEC comparison.
|
* DNSSEC comparison.
|
||||||
@@ -264,9 +263,8 @@ dns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2,
|
|||||||
*\li true if the slabs are equal, false otherwise.
|
*\li true if the slabs are equal, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
dns_rdataslab_equalx(unsigned char *slab1, unsigned char *slab2,
|
dns_rdataslab_equalx(dns_slabheader_t *slab1, dns_slabheader_t *slab2,
|
||||||
unsigned int reservelen, dns_rdataclass_t rdclass,
|
dns_rdataclass_t rdclass, dns_rdatatype_t type);
|
||||||
dns_rdatatype_t type);
|
|
||||||
/*%<
|
/*%<
|
||||||
* Compare two rdataslabs for DNSSEC equality.
|
* Compare two rdataslabs for DNSSEC equality.
|
||||||
*
|
*
|
||||||
|
@@ -2884,9 +2884,7 @@ find_header:
|
|||||||
if (ACTIVE(header, now) && header->type == dns_rdatatype_ns &&
|
if (ACTIVE(header, now) && header->type == dns_rdatatype_ns &&
|
||||||
EXISTS(header) && EXISTS(newheader) &&
|
EXISTS(header) && EXISTS(newheader) &&
|
||||||
header->trust >= newheader->trust &&
|
header->trust >= newheader->trust &&
|
||||||
dns_rdataslab_equalx((unsigned char *)header,
|
dns_rdataslab_equalx(header, newheader,
|
||||||
(unsigned char *)newheader,
|
|
||||||
(unsigned int)(sizeof(*newheader)),
|
|
||||||
qpdb->common.rdclass,
|
qpdb->common.rdclass,
|
||||||
(dns_rdatatype_t)header->type))
|
(dns_rdatatype_t)header->type))
|
||||||
{
|
{
|
||||||
@@ -2950,9 +2948,7 @@ find_header:
|
|||||||
header->type == DNS_SIGTYPE(dns_rdatatype_ds)) &&
|
header->type == DNS_SIGTYPE(dns_rdatatype_ds)) &&
|
||||||
EXISTS(header) && EXISTS(newheader) &&
|
EXISTS(header) && EXISTS(newheader) &&
|
||||||
header->trust >= newheader->trust &&
|
header->trust >= newheader->trust &&
|
||||||
dns_rdataslab_equal((unsigned char *)header,
|
dns_rdataslab_equal(header, newheader))
|
||||||
(unsigned char *)newheader,
|
|
||||||
(unsigned int)(sizeof(*newheader))))
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Honour the new ttl if it is less than the
|
* Honour the new ttl if it is less than the
|
||||||
|
@@ -714,20 +714,21 @@ dns_rdataslab_subtract(unsigned char *mslab, unsigned char *sslab,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
dns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2,
|
dns_rdataslab_equal(dns_slabheader_t *slab1, dns_slabheader_t *slab2) {
|
||||||
unsigned int reservelen) {
|
|
||||||
unsigned char *current1 = NULL, *current2 = NULL;
|
unsigned char *current1 = NULL, *current2 = NULL;
|
||||||
unsigned int count1, count2;
|
unsigned int count1, count2;
|
||||||
unsigned int length1, length2;
|
unsigned int length1, length2;
|
||||||
|
|
||||||
current1 = slab1 + reservelen;
|
current1 = (unsigned char *)slab1 + sizeof(dns_slabheader_t);
|
||||||
count1 = get_uint16(current1);
|
count1 = get_uint16(current1);
|
||||||
|
|
||||||
current2 = slab2 + reservelen;
|
current2 = (unsigned char *)slab2 + sizeof(dns_slabheader_t);
|
||||||
count2 = get_uint16(current2);
|
count2 = get_uint16(current2);
|
||||||
|
|
||||||
if (count1 != count2) {
|
if (count1 != count2) {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (count1 == 0) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (count1-- > 0) {
|
while (count1-- > 0) {
|
||||||
@@ -747,22 +748,23 @@ dns_rdataslab_equal(unsigned char *slab1, unsigned char *slab2,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
dns_rdataslab_equalx(unsigned char *slab1, unsigned char *slab2,
|
dns_rdataslab_equalx(dns_slabheader_t *slab1, dns_slabheader_t *slab2,
|
||||||
unsigned int reservelen, dns_rdataclass_t rdclass,
|
dns_rdataclass_t rdclass, dns_rdatatype_t type) {
|
||||||
dns_rdatatype_t type) {
|
|
||||||
unsigned char *current1 = NULL, *current2 = NULL;
|
unsigned char *current1 = NULL, *current2 = NULL;
|
||||||
unsigned int count1, count2;
|
unsigned int count1, count2;
|
||||||
dns_rdata_t rdata1 = DNS_RDATA_INIT;
|
dns_rdata_t rdata1 = DNS_RDATA_INIT;
|
||||||
dns_rdata_t rdata2 = DNS_RDATA_INIT;
|
dns_rdata_t rdata2 = DNS_RDATA_INIT;
|
||||||
|
|
||||||
current1 = slab1 + reservelen;
|
current1 = (unsigned char *)slab1 + sizeof(dns_slabheader_t);
|
||||||
count1 = get_uint16(current1);
|
count1 = get_uint16(current1);
|
||||||
|
|
||||||
current2 = slab2 + reservelen;
|
current2 = (unsigned char *)slab2 + sizeof(dns_slabheader_t);
|
||||||
count2 = get_uint16(current2);
|
count2 = get_uint16(current2);
|
||||||
|
|
||||||
if (count1 != count2) {
|
if (count1 != count2) {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (count1 == 0) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (count1-- > 0) {
|
while (count1-- > 0) {
|
||||||
|
Reference in New Issue
Block a user