summaryrefslogtreecommitdiff
path: root/source4/rpc_server/dnsserver
diff options
context:
space:
mode:
Diffstat (limited to 'source4/rpc_server/dnsserver')
-rw-r--r--source4/rpc_server/dnsserver/dnsdata.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/source4/rpc_server/dnsserver/dnsdata.c b/source4/rpc_server/dnsserver/dnsdata.c
index 486290dd9b..e1b7f356ff 100644
--- a/source4/rpc_server/dnsserver/dnsdata.c
+++ b/source4/rpc_server/dnsserver/dnsdata.c
@@ -707,18 +707,42 @@ int dns_name_compare(const struct ldb_message **m1, const struct ldb_message **m
return 1;
}
+ /* Compare the last components of names.
+ * If search_name is not NULL, compare the second last components of names */
ptr1 = strrchr(name1, '.');
if (ptr1 == NULL) {
ptr1 = name1;
} else {
- ptr1 = &ptr1[1];
+ if (search_name && strcmp(ptr1+1, search_name) == 0) {
+ ptr1--;
+ while (ptr1 != name1) {
+ ptr1--;
+ if (*ptr1 == '.') {
+ break;
+ }
+ }
+ }
+ if (*ptr1 == '.') {
+ ptr1 = &ptr1[1];
+ }
}
ptr2 = strrchr(name2, '.');
if (ptr2 == NULL) {
ptr2 = name2;
} else {
- ptr2 = &ptr2[1];
+ if (search_name && strcmp(ptr2+1, search_name) == 0) {
+ ptr2--;
+ while (ptr2 != name2) {
+ ptr2--;
+ if (*ptr2 == '.') {
+ break;
+ }
+ }
+ }
+ if (*ptr2 == '.') {
+ ptr2 = &ptr2[1];
+ }
}
return strcasecmp(ptr1, ptr2);