diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-02-22 15:45:44 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2011-02-28 15:54:13 -0800 |
commit | 84b884eb4bec38b721d6c38704f12d1d2c601bcb (patch) | |
tree | 165c3d5361f2f6c1866b92d6fa8a1005c19aca9b /librpc | |
parent | 6c3a49ced333988b21d86e47b2b1dd1a5957e15c (diff) | |
download | samba-84b884eb4bec38b721d6c38704f12d1d2c601bcb.tar.gz samba-84b884eb4bec38b721d6c38704f12d1d2c601bcb.tar.bz2 samba-84b884eb4bec38b721d6c38704f12d1d2c601bcb.zip |
librpc/ndr: ndr align relative pointers based on the given flags
We used to do this only for the reverse relative pointers
and now we always do it.
metze
Diffstat (limited to 'librpc')
-rw-r--r-- | librpc/ndr/ndr.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c index 068e07f84a..14f9e06337 100644 --- a/librpc/ndr/ndr.c +++ b/librpc/ndr/ndr.c @@ -1179,6 +1179,32 @@ _PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2_start(struct ndr_push *ndr, co return NDR_ERR_SUCCESS; } if (!(ndr->flags & LIBNDR_FLAG_RELATIVE_REVERSE)) { + uint32_t relative_offset; + size_t pad; + /* TODO: remove this hack and let the idl use FLAG_ALIGN2 explicit */ + size_t align = 2; + + if (ndr->offset < ndr->relative_base_offset) { + return ndr_push_error(ndr, NDR_ERR_BUFSIZE, + "ndr_push_relative_ptr2_start ndr->offset(%u) < ndr->relative_base_offset(%u)", + ndr->offset, ndr->relative_base_offset); + } + + relative_offset = ndr->offset - ndr->relative_base_offset; + + if (ndr->flags & LIBNDR_FLAG_ALIGN2) { + align = 2; + } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) { + align = 4; + } else if (ndr->flags & LIBNDR_FLAG_ALIGN8) { + align = 8; + } + + pad = ndr_align_size(relative_offset, align); + if (pad) { + NDR_CHECK(ndr_push_zero(ndr, pad)); + } + return ndr_push_relative_ptr2(ndr, p); } if (ndr->relative_end_offset == -1) { |