From 72c8ccd408070bcb3defba34865d31a1ea6311fe Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sun, 3 Oct 2010 12:21:00 +0200 Subject: s4 dns: Implement update record prescan logic Autobuild-User: Kai Blin Autobuild-Date: Sat Oct 23 10:58:18 UTC 2010 on sn-devel-104 --- source4/dns_server/dns_update.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'source4') 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; } -- cgit