s4:rpc-dnsserver: Fix the enumeration of DNS records
authorAmitay Isaacs <amitay@gmail.com>
Thu, 15 Dec 2011 08:45:22 +0000 (19:45 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 23 Dec 2011 05:18:24 +0000 (16:18 +1100)
If a node has data and children, do not return the children unless
the node is the top level node.

source4/rpc_server/dnsserver/dnsdata.c

index 535996036d312855abdd6f0791fd7fc6e6594454..b2ab2d9ff510d695499a4b5224925c462eddbaee 100644 (file)
@@ -617,6 +617,11 @@ struct dns_tree *dns_build_tree(TALLOC_CTX *mem_ctx, const char *name, struct ld
                        goto failed;
                }
 
+               /* If the node is on leaf, then add record data */
+               if (match_count+1 == ncount) {
+                       tree->data = res->msgs[i];
+               }
+
                /* Add missing name components */
                for (level=match_count+1; level<ncount; level++) {
                        if (tree->level == rootcount+1) {
@@ -754,6 +759,11 @@ WERROR dns_fill_records_array(TALLOC_CTX *mem_ctx,
                return WERR_OK;
        }
 
+       /* Do not return RR records, if the node has children */
+       if (branch_name != NULL && num_children > 0) {
+               return WERR_OK;
+       }
+
        ptr = ldb_msg_find_attr_as_string(msg, "name", NULL);
        el = ldb_msg_find_element(msg, "dnsRecord");
        if (el == NULL || el->values == 0) {