summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/dns_server/dns_update.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/source4/dns_server/dns_update.c b/source4/dns_server/dns_update.c
index 81e3fce599..f789f2d625 100644
--- a/source4/dns_server/dns_update.c
+++ b/source4/dns_server/dns_update.c
@@ -91,6 +91,40 @@ static WERROR check_prerequsites(struct dns_server *dns,
return WERR_OK;
}
+static WERROR update_prescan(const struct dns_name_question *zone,
+ const struct dns_res_rec *updates, uint16_t count)
+{
+ const struct dns_res_rec *r;
+ uint16_t i;
+ size_t host_part_len;
+ bool match;
+
+ for (i = 0; i < count; i++) {
+ r = &updates[i];
+ match = dns_name_match(zone->name, r->name, &host_part_len);
+ if (!match) {
+ return DNS_ERR(NOTZONE);
+ }
+ if (zone->question_class == r->rr_class) {
+ /*TODO: also check for AXFR,MAILA,MAILB */
+ if (r->rr_type == DNS_QTYPE_ALL) {
+ return DNS_ERR(FORMAT_ERROR);
+ }
+ } else if (r->rr_class == DNS_QCLASS_ANY) {
+ if (r->ttl != 0 || r->length != 0) {
+ return DNS_ERR(FORMAT_ERROR);
+ }
+ } else if (r->rr_class == DNS_QCLASS_NONE) {
+ if (r->ttl != 0 || r->rr_type == DNS_QTYPE_ALL) {
+ return DNS_ERR(FORMAT_ERROR);
+ }
+ } else {
+ return DNS_ERR(FORMAT_ERROR);
+ }
+ }
+ return WERR_OK;
+}
+
WERROR dns_server_process_update(struct dns_server *dns,
TALLOC_CTX *mem_ctx,
struct dns_name_packet *in,
@@ -144,5 +178,8 @@ WERROR dns_server_process_update(struct dns_server *dns,
return DNS_ERR(REFUSED);
}
+ werror = update_prescan(in->questions, *updates, *update_count);
+ W_ERROR_NOT_OK_RETURN(werror);
+
return werror;
}