summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-12-16 22:54:02 +0100
committerStefan Metzmacher <metze@samba.org>2010-02-18 13:44:01 +0100
commitc9fa97b01774d767acfabaf1eec7a6aad1510440 (patch)
tree1c47f0d1a70e38bbd0a3c85c64dcd26b2ddd0321
parent98e143cd31fe10a039a4110f4d3755dee62ee826 (diff)
downloadsamba-c9fa97b01774d767acfabaf1eec7a6aad1510440.tar.gz
samba-c9fa97b01774d767acfabaf1eec7a6aad1510440.tar.bz2
samba-c9fa97b01774d767acfabaf1eec7a6aad1510440.zip
libndr: change subcontext buffer allocation to allocate on subcontext_start.
Guenther
-rw-r--r--librpc/ndr/ndr.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index 90ecdb1584..80025d71f0 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -590,6 +590,11 @@ _PUBLIC_ enum ndr_err_code ndr_push_subcontext_start(struct ndr_push *ndr,
NDR_ERR_HAVE_NO_MEMORY(subndr);
subndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64;
+ if (size_is > 0) {
+ NDR_CHECK(ndr_push_zero(subndr, size_is));
+ subndr->offset = 0;
+ }
+
*_subndr = subndr;
return NDR_ERR_SUCCESS;
}
@@ -606,12 +611,11 @@ _PUBLIC_ enum ndr_err_code ndr_push_subcontext_end(struct ndr_push *ndr,
if (size_is >= 0) {
padding_len = size_is - subndr->offset;
- if (padding_len > 0) {
- NDR_CHECK(ndr_push_zero(subndr, padding_len));
- } else if (padding_len < 0) {
+ if (padding_len < 0) {
return ndr_push_error(ndr, NDR_ERR_SUBCONTEXT, "Bad subcontext (PUSH) content_size %d is larger than size_is(%d)",
(int)subndr->offset, (int)size_is);
}
+ subndr->offset = size_is;
}
switch (header_size) {