summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-09-30 01:49:32 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:14 -0500
commitf1c52270785285fcf68e2b22fbc83cbee38910fd (patch)
tree9f150673e7729df6a3bae98b79df4cf66deb2714 /source4/librpc/ndr
parent9bc38ce65f1907230618b3edccafb1d33f753fe0 (diff)
downloadsamba-f1c52270785285fcf68e2b22fbc83cbee38910fd.tar.gz
samba-f1c52270785285fcf68e2b22fbc83cbee38910fd.tar.bz2
samba-f1c52270785285fcf68e2b22fbc83cbee38910fd.zip
r10637: use the correct memory context in the ndr_pull_* function
to build the talloc hierachie correct metze (This used to be commit afd9dda5773d381550bdb061a8e345b33e1fc371)
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r--source4/librpc/ndr/ndr_basic.c4
-rw-r--r--source4/librpc/ndr/ndr_string.c42
2 files changed, 29 insertions, 17 deletions
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c
index b3740c5e01..23e686f76f 100644
--- a/source4/librpc/ndr/ndr_basic.c
+++ b/source4/librpc/ndr/ndr_basic.c
@@ -559,7 +559,7 @@ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **
struct ipv4_addr in;
NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &in.addr));
in.addr = htonl(in.addr);
- *address = talloc_strdup(ndr, sys_inet_ntoa(in));
+ *address = talloc_strdup(ndr->current_mem_ctx, sys_inet_ntoa(in));
NT_STATUS_HAVE_NO_MEMORY(*address);
return NT_STATUS_OK;
}
@@ -802,7 +802,7 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &length));
}
NDR_PULL_NEED_BYTES(ndr, length);
- *blob = data_blob_talloc(ndr, ndr->data+ndr->offset, length);
+ *blob = data_blob_talloc(ndr->current_mem_ctx, ndr->data+ndr->offset, length);
ndr->offset += length;
return NT_STATUS_OK;
}
diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c
index a007f7c188..ce035be5dc 100644
--- a/source4/librpc/ndr/ndr_string.c
+++ b/source4/librpc/ndr/ndr_string.c
@@ -81,9 +81,10 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
}
NDR_PULL_NEED_BYTES(ndr, (len2 + c_len_term)*byte_mul);
if (len2 == 0) {
- as = talloc_strdup(ndr, "");
+ as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ret = convert_string_talloc(ndr->current_mem_ctx,
+ chset, CH_UNIX,
ndr->data+ndr->offset,
(len2 + c_len_term)*byte_mul,
(void **)&as);
@@ -125,9 +126,10 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1));
NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul);
if (len1 == 0) {
- as = talloc_strdup(ndr, "");
+ as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ret = convert_string_talloc(ndr->current_mem_ctx,
+ chset, CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
(void **)&as);
@@ -162,9 +164,10 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &len1));
NDR_PULL_NEED_BYTES(ndr, (len1 + c_len_term)*byte_mul);
if (len1 == 0) {
- as = talloc_strdup(ndr, "");
+ as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ret = convert_string_talloc(ndr->current_mem_ctx,
+ chset, CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
(void **)&as);
@@ -195,9 +198,10 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &len3));
NDR_PULL_NEED_BYTES(ndr, (len3 + c_len_term)*byte_mul);
if (len3 == 0) {
- as = talloc_strdup(ndr, "");
+ as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ret = convert_string_talloc(ndr->current_mem_ctx,
+ chset, CH_UNIX,
ndr->data+ndr->offset,
(len3 + c_len_term)*byte_mul,
(void **)&as);
@@ -226,9 +230,10 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &len3));
NDR_PULL_NEED_BYTES(ndr, len3);
if (len3 == 0) {
- as = talloc_strdup(ndr, "");
+ as = talloc_strdup(ndr->current_mem_ctx, "");
} else {
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ret = convert_string_talloc(ndr->current_mem_ctx,
+ chset, CH_UNIX,
ndr->data+ndr->offset,
len3,
(void **)&as);
@@ -247,7 +252,8 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
} else {
len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
}
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ret = convert_string_talloc(ndr->current_mem_ctx,
+ chset, CH_UNIX,
ndr->data+ndr->offset,
len1,
(void **)&as);
@@ -263,7 +269,8 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
case LIBNDR_FLAG_STR_FIXLEN32:
len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15;
NDR_PULL_NEED_BYTES(ndr, len1*byte_mul);
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ret = convert_string_talloc(ndr->current_mem_ctx,
+ chset, CH_UNIX,
ndr->data+ndr->offset,
len1*byte_mul,
(void **)&as);
@@ -530,13 +537,17 @@ NTSTATUS ndr_pull_string_array(struct ndr_pull *ndr, int ndr_flags, const char *
}
for (count = 0;; count++) {
+ TALLOC_CTX *tmp_ctx;
const char *s = NULL;
- a = talloc_realloc(ndr, a, const char *, count + 2);
+ a = talloc_realloc(ndr->current_mem_ctx, a, const char *, count + 2);
NT_STATUS_HAVE_NO_MEMORY(a);
a[count] = NULL;
a[count+1] = NULL;
+ tmp_ctx = ndr->current_mem_ctx;
+ ndr->current_mem_ctx = a;
NDR_CHECK(ndr_pull_string(ndr, ndr_flags, &s));
+ ndr->current_mem_ctx = tmp_ctx;
if (strcmp("", s)==0) {
a[count] = NULL;
break;
@@ -622,11 +633,12 @@ NTSTATUS ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var,
{
int ret;
if (length == 0) {
- *var = talloc_strdup(ndr, "");
+ *var = talloc_strdup(ndr->current_mem_ctx, "");
return NT_STATUS_OK;
}
NDR_PULL_NEED_BYTES(ndr, length*byte_mul);
- ret = convert_string_talloc(ndr, chset, CH_UNIX,
+ ret = convert_string_talloc(ndr->current_mem_ctx,
+ chset, CH_UNIX,
ndr->data+ndr->offset,
length*byte_mul,
discard_const_p(void *, var));