summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2012-09-27 01:22:57 -0700
committerMatthieu Patou <mat@matws.net>2012-10-07 21:51:02 -0700
commit03c4dceaab82ca2c60c9ce0e09fddd071f98087b (patch)
tree2990d2015ba7948d9046fa72e41b9108440bce7f
parent85259635d60bc29421a878ec4118d4449c9a359d (diff)
downloadsamba-03c4dceaab82ca2c60c9ce0e09fddd071f98087b.tar.gz
samba-03c4dceaab82ca2c60c9ce0e09fddd071f98087b.tar.bz2
samba-03c4dceaab82ca2c60c9ce0e09fddd071f98087b.zip
lib-addns: ensure that allocated buffer are pre set to 0
It avoid bugs when one of the buffer is supposed to contain a string that is not null terminated (ie. label->label) and that we don't force the last byte to 0.
-rw-r--r--lib/addns/dnsmarshall.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/addns/dnsmarshall.c b/lib/addns/dnsmarshall.c
index b0211c8a40..846fd5bf16 100644
--- a/lib/addns/dnsmarshall.c
+++ b/lib/addns/dnsmarshall.c
@@ -27,7 +27,7 @@ struct dns_buffer *dns_create_buffer(TALLOC_CTX *mem_ctx)
{
struct dns_buffer *result;
- if (!(result = talloc(mem_ctx, struct dns_buffer))) {
+ if (!(result = talloc_zero(mem_ctx, struct dns_buffer))) {
return NULL;
}
@@ -39,7 +39,7 @@ struct dns_buffer *dns_create_buffer(TALLOC_CTX *mem_ctx)
*/
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;
}
@@ -216,14 +216,14 @@ static void dns_unmarshall_label(TALLOC_CTX *mem_ctx,
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;
- 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;
}
@@ -250,7 +250,7 @@ void dns_unmarshall_domain_name(TALLOC_CTX *mem_ctx,
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;
}
@@ -281,7 +281,7 @@ static void dns_unmarshall_question(TALLOC_CTX *mem_ctx,
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;
}
@@ -314,7 +314,7 @@ static void dns_unmarshall_rr(TALLOC_CTX *mem_ctx,
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;
}
@@ -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 (!(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;
}
@@ -406,22 +406,22 @@ DNS_ERROR dns_unmarshall_request(TALLOC_CTX *mem_ctx,
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->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->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->additionals = talloc_array(req, struct dns_rrec *,
+ !(req->additionals = talloc_zero_array(req, struct dns_rrec *,
req->num_additionals))) {
goto error;
}