aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES5
-rw-r--r--lib/dns/rdata.c4
-rw-r--r--lib/dns/rdataslab.c11
-rw-r--r--version2
4 files changed, 16 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 821e905d53c6..9a505f5eed57 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+ --- 9.6-ESV-R7-P1 released ---
+
+3331. [security] dns_rdataslab_fromrdataset could produce bad
+ rdataslabs. [RT #29644]
+
--- 9.6-ESV-R7 released ---
3318. [tuning] Reduce the amount of work performed while holding a
diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c
index 150e2eaa1bc5..c504f48d5790 100644
--- a/lib/dns/rdata.c
+++ b/lib/dns/rdata.c
@@ -345,8 +345,8 @@ dns_rdata_compare(const dns_rdata_t *rdata1, const dns_rdata_t *rdata2) {
REQUIRE(rdata1 != NULL);
REQUIRE(rdata2 != NULL);
- REQUIRE(rdata1->data != NULL);
- REQUIRE(rdata2->data != NULL);
+ REQUIRE(rdata1->length == 0 || rdata1->data != NULL);
+ REQUIRE(rdata2->length == 0 || rdata2->data != NULL);
REQUIRE(DNS_RDATA_VALIDFLAGS(rdata1));
REQUIRE(DNS_RDATA_VALIDFLAGS(rdata2));
diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c
index c5f4a52c8917..d5752adc53e1 100644
--- a/lib/dns/rdataslab.c
+++ b/lib/dns/rdataslab.c
@@ -126,6 +126,11 @@ isc_result_t
dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
isc_region_t *region, unsigned int reservelen)
{
+ /*
+ * Use &removed as a sentinal pointer for duplicate
+ * rdata as rdata.data == NULL is valid.
+ */
+ static unsigned char removed;
struct xrdata *x;
unsigned char *rawbuf;
#if DNS_RDATASET_FIXED
@@ -165,6 +170,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
INSIST(result == ISC_R_SUCCESS);
dns_rdata_init(&x[i].rdata);
dns_rdataset_current(rdataset, &x[i].rdata);
+ INSIST(x[i].rdata.data != &removed);
#if DNS_RDATASET_FIXED
x[i].order = i;
#endif
@@ -197,8 +203,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
*/
for (i = 1; i < nalloc; i++) {
if (compare_rdata(&x[i-1].rdata, &x[i].rdata) == 0) {
- x[i-1].rdata.data = NULL;
- x[i-1].rdata.length = 0;
+ x[i-1].rdata.data = &removed;
#if DNS_RDATASET_FIXED
/*
* Preserve the least order so A, B, A -> A, B
@@ -285,7 +290,7 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx,
#endif
for (i = 0; i < nalloc; i++) {
- if (x[i].rdata.data == NULL)
+ if (x[i].rdata.data == &removed)
continue;
#if DNS_RDATASET_FIXED
offsettable[x[i].order] = rawbuf - offsetbase;
diff --git a/version b/version
index 103d10e60fdf..93b5f3900c00 100644
--- a/version
+++ b/version
@@ -7,4 +7,4 @@ MAJORVER=9
MINORVER=6
PATCHVER=
RELEASETYPE=-ESV
-RELEASEVER=-R7
+RELEASEVER=-R7-P1