summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) {