|
|
1a4de8 |
From 9c1f74400c04267dea4f1bd7f62de8ba5e8d2b0e Mon Sep 17 00:00:00 2001
|
|
|
1a4de8 |
From: Mark Andrews <marka@isc.org>
|
|
|
1a4de8 |
Date: Thu, 28 Nov 2019 10:24:12 +1100
|
|
|
1a4de8 |
Subject: [PATCH 4/4] rdataset_setownercase and rdataset_getownercase need to
|
|
|
1a4de8 |
obtain a node lock
|
|
|
1a4de8 |
|
|
|
1a4de8 |
(cherry picked from commit 637b2c4e517b466900a8c00b52f7a15727e12ae9)
|
|
|
1a4de8 |
(cherry picked from commit 1c61f129c3b12071723a2154d33f74628bf80998)
|
|
|
1a4de8 |
---
|
|
|
1a4de8 |
lib/dns/rbtdb.c | 35 ++++++++++++++++++++++++++++-------
|
|
|
1a4de8 |
1 file changed, 28 insertions(+), 7 deletions(-)
|
|
|
1a4de8 |
|
|
|
1a4de8 |
diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c
|
|
|
1a4de8 |
index d3bb8d7fe7..199ff08011 100644
|
|
|
1a4de8 |
--- a/lib/dns/rbtdb.c
|
|
|
1a4de8 |
+++ b/lib/dns/rbtdb.c
|
|
|
1a4de8 |
@@ -10109,11 +10109,18 @@ setownercase(rdatasetheader_t *header, const dns_name_t *name) {
|
|
|
1a4de8 |
|
|
|
1a4de8 |
static void
|
|
|
1a4de8 |
rdataset_setownercase(dns_rdataset_t *rdataset, const dns_name_t *name) {
|
|
|
1a4de8 |
+ dns_rbtdb_t *rbtdb = rdataset->private1;
|
|
|
1a4de8 |
+ dns_rbtnode_t *rbtnode = rdataset->private2;
|
|
|
1a4de8 |
unsigned char *raw = rdataset->private3; /* RDATASLAB */
|
|
|
1a4de8 |
rdatasetheader_t *header;
|
|
|
1a4de8 |
|
|
|
1a4de8 |
header = (struct rdatasetheader *)(raw - sizeof(*header));
|
|
|
1a4de8 |
+
|
|
|
1a4de8 |
+ NODE_LOCK(&rbtdb->node_locks[rbtnode->locknum].lock,
|
|
|
1a4de8 |
+ isc_rwlocktype_write);
|
|
|
1a4de8 |
setownercase(header, name);
|
|
|
1a4de8 |
+ NODE_UNLOCK(&rbtdb->node_locks[rbtnode->locknum].lock,
|
|
|
1a4de8 |
+ isc_rwlocktype_write);
|
|
|
1a4de8 |
}
|
|
|
1a4de8 |
|
|
|
1a4de8 |
static const unsigned char charmask[] = {
|
|
|
1a4de8 |
@@ -10188,6 +10195,8 @@ static unsigned char maptolower[] = {
|
|
|
1a4de8 |
|
|
|
1a4de8 |
static void
|
|
|
1a4de8 |
rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) {
|
|
|
1a4de8 |
+ dns_rbtdb_t *rbtdb = rdataset->private1;
|
|
|
1a4de8 |
+ dns_rbtnode_t *rbtnode = rdataset->private2;
|
|
|
1a4de8 |
const unsigned char *raw = rdataset->private3; /* RDATASLAB */
|
|
|
1a4de8 |
const rdatasetheader_t *header;
|
|
|
1a4de8 |
unsigned int i, j;
|
|
|
1a4de8 |
@@ -10196,8 +10205,12 @@ rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) {
|
|
|
1a4de8 |
|
|
|
1a4de8 |
header = (const struct rdatasetheader *)(raw - sizeof(*header));
|
|
|
1a4de8 |
|
|
|
1a4de8 |
- if (!CASESET(header))
|
|
|
1a4de8 |
- return;
|
|
|
1a4de8 |
+ NODE_LOCK(&rbtdb->node_locks[rbtnode->locknum].lock,
|
|
|
1a4de8 |
+ isc_rwlocktype_read);
|
|
|
1a4de8 |
+
|
|
|
1a4de8 |
+ if (!CASESET(header)) {
|
|
|
1a4de8 |
+ goto unlock;
|
|
|
1a4de8 |
+ }
|
|
|
1a4de8 |
|
|
|
1a4de8 |
#if 0
|
|
|
1a4de8 |
/*
|
|
|
1a4de8 |
@@ -10210,10 +10223,13 @@ rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) {
|
|
|
1a4de8 |
*/
|
|
|
1a4de8 |
if (name->ndata[i] >= 0x61 && name->ndata[i] <= 0x7a &&
|
|
|
1a4de8 |
(header->upper[i/8] & (1 << (i%8))) != 0)
|
|
|
1a4de8 |
+ {
|
|
|
1a4de8 |
name->ndata[i] &= ~0x20; /* clear the lower case bit */
|
|
|
1a4de8 |
- else if (name->ndata[i] >= 0x41 && name->ndata[i] <= 0x5a &&
|
|
|
1a4de8 |
- (header->upper[i/8] & (1 << (i%8))) == 0)
|
|
|
1a4de8 |
+ } else if (name->ndata[i] >= 0x41 && name->ndata[i] <= 0x5a &&
|
|
|
1a4de8 |
+ (header->upper[i/8] & (1 << (i%8))) == 0)
|
|
|
1a4de8 |
+ {
|
|
|
1a4de8 |
name->ndata[i] |= 0x20; /* set the lower case bit */
|
|
|
1a4de8 |
+ }
|
|
|
1a4de8 |
}
|
|
|
1a4de8 |
#else
|
|
|
1a4de8 |
if (ISC_LIKELY(CASEFULLYLOWER(header))) {
|
|
|
1a4de8 |
@@ -10236,7 +10252,7 @@ rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) {
|
|
|
1a4de8 |
c = *bp;
|
|
|
1a4de8 |
*bp++ = maptolower[c];
|
|
|
1a4de8 |
}
|
|
|
1a4de8 |
- return;
|
|
|
1a4de8 |
+ goto unlock;
|
|
|
1a4de8 |
}
|
|
|
1a4de8 |
|
|
|
1a4de8 |
i = 0;
|
|
|
1a4de8 |
@@ -10257,8 +10273,9 @@ rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) {
|
|
|
1a4de8 |
}
|
|
|
1a4de8 |
}
|
|
|
1a4de8 |
|
|
|
1a4de8 |
- if (ISC_UNLIKELY(i == name->length))
|
|
|
1a4de8 |
- return;
|
|
|
1a4de8 |
+ if (ISC_UNLIKELY(i == name->length)) {
|
|
|
1a4de8 |
+ goto unlock;
|
|
|
1a4de8 |
+ }
|
|
|
1a4de8 |
|
|
|
1a4de8 |
bits = ~(header->upper[j]);
|
|
|
1a4de8 |
|
|
|
1a4de8 |
@@ -10272,6 +10289,10 @@ rdataset_getownercase(const dns_rdataset_t *rdataset, dns_name_t *name) {
|
|
|
1a4de8 |
bits >>= 1;
|
|
|
1a4de8 |
}
|
|
|
1a4de8 |
#endif
|
|
|
1a4de8 |
+
|
|
|
1a4de8 |
+ unlock:
|
|
|
1a4de8 |
+ NODE_UNLOCK(&rbtdb->node_locks[rbtnode->locknum].lock,
|
|
|
1a4de8 |
+ isc_rwlocktype_read);
|
|
|
1a4de8 |
}
|
|
|
1a4de8 |
|
|
|
1a4de8 |
/*%
|
|
|
1a4de8 |
--
|
|
|
1a4de8 |
2.21.0
|
|
|
1a4de8 |
|