dns: Do as BIND and MS DNS and drop quries with qdcount != 1
authorKai Blin <kai@samba.org>
Tue, 27 Sep 2011 05:31:46 +0000 (22:31 -0700)
committerKai Blin <kai@samba.org>
Wed, 28 Sep 2011 01:37:22 +0000 (03:37 +0200)
Autobuild-User: Kai Blin <kai@samba.org>
Autobuild-Date: Wed Sep 28 03:37:22 CEST 2011 on sn-devel-104

source4/dns_server/dns_query.c

index d96877e9bd39dacbd36b2e2128e0ffad14c5684a..2153ad92458c898ec3421730edb1746c05001037 100644 (file)
@@ -206,17 +206,19 @@ WERROR dns_server_process_query(struct dns_server *dns,
                                struct dns_res_rec **nsrecs,     uint16_t *nscount,
                                struct dns_res_rec **additional, uint16_t *arcount)
 {
-       uint16_t i, num_answers=0;
+       uint16_t num_answers=0;
        struct dns_res_rec *ans=NULL;
        WERROR werror;
 
+       if (in->qdcount != 1) {
+               return DNS_ERR(FORMAT_ERROR);
+       }
+
        ans = talloc_array(mem_ctx, struct dns_res_rec, 0);
        W_ERROR_HAVE_NO_MEMORY(ans);
 
-       for (i = 0; i < in->qdcount; ++i) {
-               werror = handle_question(dns, mem_ctx, &in->questions[i], &ans, &num_answers);
-               W_ERROR_NOT_OK_RETURN(werror);
-       }
+       werror = handle_question(dns, mem_ctx, &in->questions[0], &ans, &num_answers);
+       W_ERROR_NOT_OK_GOTO(werror, query_failed);
 
        *answers = ans;
        *ancount = num_answers;
@@ -229,4 +231,8 @@ WERROR dns_server_process_query(struct dns_server *dns,
        *arcount    = 0;
 
        return WERR_OK;
+
+query_failed:
+       /*FIXME: add our SOA record to nsrecs */
+       return werror;
 }