Commit d33c9b436d for bind
commit d33c9b436db7c1be3ccb5e3efaa3de27cb9b75ee
Author: Evan Hunt <each@isc.org>
Date: Thu Oct 15 17:37:37 2026 -0700
don't compare negative data in dns_rdataslab_equalx()
dns_rdataslab_equalx() checks DNSSEC equality of two rdataslabs,
normaizing the rdatas and comparing them with dns_rdata_compare().
since this is not meaningful with slabs containing negative data,
it now uses memcmp() instead of dns_rdata_compare() when either slab
is negative.
diff --git a/lib/dns/include/dns/rdataslab.h b/lib/dns/include/dns/rdataslab.h
index 85ceafc50b..752e08f58a 100644
--- a/lib/dns/include/dns/rdataslab.h
+++ b/lib/dns/include/dns/rdataslab.h
@@ -229,13 +229,19 @@ bool
dns_rdataslab_equalx(dns_slabheader_t *header1, dns_slabheader_t *header2,
dns_rdataclass_t rdclass, dns_rdatatype_t type);
/*%<
- * Compare two rdataslabs for DNSSEC equality.
+ * Compare two positive rdataslabs for DNSSEC equality, normalizing
+ * the rdata.
+ *
+ * If either slab contains negative records, compare them using
+ * dns_rdataslab_equal(), because they have no positive rdata for the type,
+ * so rdata comparison isn't meaningful.
*
* Requires:
*\li 'header1' and 'header2' point to slab headers followed by slabs.
*
* Returns:
- *\li true if the slabs are equal, #false otherwise.
+ *\li true iff. both slabs are positive and they are DNSSEC-equal,
+ * or if either slab is negative and they are byte-equal.
*/
#define dns_slabheader_reset(header, node) \
diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c
index cf8302525a..5ec03806fd 100644
--- a/lib/dns/rdataslab.c
+++ b/lib/dns/rdataslab.c
@@ -479,6 +479,14 @@ dns_rdataslab_equalx(dns_slabheader_t *slab1, dns_slabheader_t *slab2,
unsigned char *current1 = NULL, *current2 = NULL;
unsigned int count1, count2;
+ /*
+ * Comparing negative slabs for DNSSEC equality isn't meaningful;
+ * they don't contain rdata for the type.
+ */
+ if (NEGATIVE(slab1) || NEGATIVE(slab2)) {
+ return dns_rdataslab_equal(slab1, slab2);
+ }
+
current1 = (unsigned char *)slab1 + sizeof(dns_slabheader_t);
count1 = slab1->nitems;