lib/addns: don't depend on the order in resp->answers[]
[sfrench/samba-autobuild/.git] / lib / addns / dnsmarshall.c
index b0211c8a40c86ed7747f8b618ec16908304de4e6..846fd5bf16ae38f53a407bfd7e01b0625f79cbf6 100644 (file)
@@ -27,7 +27,7 @@ struct dns_buffer *dns_create_buffer(TALLOC_CTX *mem_ctx)
 {
        struct dns_buffer *result;
 
 {
        struct dns_buffer *result;
 
-       if (!(result = talloc(mem_ctx, struct dns_buffer))) {
+       if (!(result = talloc_zero(mem_ctx, struct dns_buffer))) {
                return NULL;
        }
 
                return NULL;
        }
 
@@ -39,7 +39,7 @@ struct dns_buffer *dns_create_buffer(TALLOC_CTX *mem_ctx)
         */
        result->size = 2;
 
         */
        result->size = 2;
 
-       if (!(result->data = talloc_array(result, uint8_t, result->size))) {
+       if (!(result->data = talloc_zero_array(result, uint8_t, result->size))) {
                TALLOC_FREE(result);
                return NULL;
        }
                TALLOC_FREE(result);
                return NULL;
        }
@@ -216,14 +216,14 @@ static void dns_unmarshall_label(TALLOC_CTX *mem_ctx,
                return;
        }
 
                return;
        }
 
-       if (!(label = talloc(mem_ctx, struct dns_domain_label))) {
+       if (!(label = talloc_zero(mem_ctx, struct dns_domain_label))) {
                buf->error = ERROR_DNS_NO_MEMORY;
                return;
        }
 
        label->len = len;
 
                buf->error = ERROR_DNS_NO_MEMORY;
                return;
        }
 
        label->len = len;
 
-       if (!(label->label = talloc_array(label, char, len+1))) {
+       if (!(label->label = talloc_zero_array(label, char, len+1))) {
                buf->error = ERROR_DNS_NO_MEMORY;
                goto error;
        }
                buf->error = ERROR_DNS_NO_MEMORY;
                goto error;
        }
@@ -250,7 +250,7 @@ void dns_unmarshall_domain_name(TALLOC_CTX *mem_ctx,
 
        if (!ERR_DNS_IS_OK(buf->error)) return;
 
 
        if (!ERR_DNS_IS_OK(buf->error)) return;
 
-       if (!(name = talloc(mem_ctx, struct dns_domain_name))) {
+       if (!(name = talloc_zero(mem_ctx, struct dns_domain_name))) {
                buf->error = ERROR_DNS_NO_MEMORY;
                return;
        }
                buf->error = ERROR_DNS_NO_MEMORY;
                return;
        }
@@ -281,7 +281,7 @@ static void dns_unmarshall_question(TALLOC_CTX *mem_ctx,
 
        if (!(ERR_DNS_IS_OK(buf->error))) return;
 
 
        if (!(ERR_DNS_IS_OK(buf->error))) return;
 
-       if (!(q = talloc(mem_ctx, struct dns_question))) {
+       if (!(q = talloc_zero(mem_ctx, struct dns_question))) {
                buf->error = ERROR_DNS_NO_MEMORY;
                return;
        }
                buf->error = ERROR_DNS_NO_MEMORY;
                return;
        }
@@ -314,7 +314,7 @@ static void dns_unmarshall_rr(TALLOC_CTX *mem_ctx,
 
        if (!(ERR_DNS_IS_OK(buf->error))) return;
 
 
        if (!(ERR_DNS_IS_OK(buf->error))) return;
 
-       if (!(r = talloc(mem_ctx, struct dns_rrec))) {
+       if (!(r = talloc_zero(mem_ctx, struct dns_rrec))) {
                buf->error = ERROR_DNS_NO_MEMORY;
                return;
        }
                buf->error = ERROR_DNS_NO_MEMORY;
                return;
        }
@@ -329,7 +329,7 @@ static void dns_unmarshall_rr(TALLOC_CTX *mem_ctx,
        if (!(ERR_DNS_IS_OK(buf->error))) return;
 
        if (r->data_length != 0) {
        if (!(ERR_DNS_IS_OK(buf->error))) return;
 
        if (r->data_length != 0) {
-               if (!(r->data = talloc_array(r, uint8_t, r->data_length))) {
+               if (!(r->data = talloc_zero_array(r, uint8_t, r->data_length))) {
                        buf->error = ERROR_DNS_NO_MEMORY;
                        return;
                }
                        buf->error = ERROR_DNS_NO_MEMORY;
                        return;
                }
@@ -406,22 +406,22 @@ DNS_ERROR dns_unmarshall_request(TALLOC_CTX *mem_ctx,
        err = ERROR_DNS_NO_MEMORY;
 
        if ((req->num_questions != 0) &&
        err = ERROR_DNS_NO_MEMORY;
 
        if ((req->num_questions != 0) &&
-           !(req->questions = talloc_array(req, struct dns_question *,
+           !(req->questions = talloc_zero_array(req, struct dns_question *,
                                            req->num_questions))) {
                goto error;
        }
        if ((req->num_answers != 0) &&
                                            req->num_questions))) {
                goto error;
        }
        if ((req->num_answers != 0) &&
-           !(req->answers = talloc_array(req, struct dns_rrec *,
+           !(req->answers = talloc_zero_array(req, struct dns_rrec *,
                                          req->num_answers))) {
                goto error;
        }
        if ((req->num_auths != 0) &&
                                          req->num_answers))) {
                goto error;
        }
        if ((req->num_auths != 0) &&
-           !(req->auths = talloc_array(req, struct dns_rrec *,
+           !(req->auths = talloc_zero_array(req, struct dns_rrec *,
                                        req->num_auths))) {
                goto error;
        }
        if ((req->num_additionals != 0) &&
                                        req->num_auths))) {
                goto error;
        }
        if ((req->num_additionals != 0) &&
-           !(req->additionals = talloc_array(req, struct dns_rrec *,
+           !(req->additionals = talloc_zero_array(req, struct dns_rrec *,
                                              req->num_additionals))) {
                goto error;
        }
                                              req->num_additionals))) {
                goto error;
        }