diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-12 05:34:21 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-12 05:34:21 +0000 |
commit | 6714815f014ae1b31d0675214d023e3afe2389f0 (patch) | |
tree | 386065e7ba271b3fad572d0fab4605bdd7878fca /source4/librpc/ndr/ndr.c | |
parent | 6735b72a8d0a8e0be274208c84b65db2fa33d2a0 (diff) | |
download | samba-6714815f014ae1b31d0675214d023e3afe2389f0.tar.gz samba-6714815f014ae1b31d0675214d023e3afe2389f0.tar.bz2 samba-6714815f014ae1b31d0675214d023e3afe2389f0.zip |
lsa_PrivilegeSet seems to be a very strange beast indeed. It has a
constant sized array of size 1 at the end?
(This used to be commit 2cc354bd82456cb5598eb4acb40a5ada1459d08d)
Diffstat (limited to 'source4/librpc/ndr/ndr.c')
-rw-r--r-- | source4/librpc/ndr/ndr.c | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 6401523028..eebc2ac681 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -167,7 +167,10 @@ NTSTATUS ndr_push_expand(struct ndr_push *ndr, uint32 size) return NT_STATUS_OK; } - ndr->alloc_size = size; + ndr->alloc_size += NDR_BASE_MARSHALL_SIZE; + if (size > ndr->alloc_size) { + ndr->alloc_size = size; + } ndr->data = talloc_realloc(ndr->mem_ctx, ndr->data, ndr->alloc_size); if (!ndr->data) { return NT_STATUS_NO_MEMORY; @@ -189,13 +192,12 @@ NTSTATUS ndr_push_set_offset(struct ndr_push *ndr, uint32 ofs) /* push a generic array */ -NTSTATUS ndr_push_array(struct ndr_push *ndr, int ndr_flags, void *base, - size_t elsize, uint32 count, - NTSTATUS (*push_fn)(struct ndr_push *, int, void *)) +NTSTATUS ndr_push_const_array(struct ndr_push *ndr, int ndr_flags, void *base, + size_t elsize, uint32 count, + NTSTATUS (*push_fn)(struct ndr_push *, int, void *)) { int i; char *p = base; - NDR_CHECK(ndr_push_uint32(ndr, count)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; for (i=0;i<count;i++) { NDR_CHECK(push_fn(ndr, NDR_SCALARS, p)); @@ -213,21 +215,26 @@ done: } /* - pull a generic array + push a generic array */ -NTSTATUS ndr_pull_array(struct ndr_pull *ndr, int ndr_flags, void *base, +NTSTATUS ndr_push_array(struct ndr_push *ndr, int ndr_flags, void *base, size_t elsize, uint32 count, - NTSTATUS (*pull_fn)(struct ndr_pull *, int, void *)) + NTSTATUS (*push_fn)(struct ndr_push *, int, void *)) +{ + NDR_CHECK(ndr_push_uint32(ndr, count)); + return ndr_push_const_array(ndr, ndr_flags, base, elsize, count, push_fn); +} + +/* + pull a constant sized array +*/ +NTSTATUS ndr_pull_const_array(struct ndr_pull *ndr, int ndr_flags, void *base, + size_t elsize, uint32 count, + NTSTATUS (*pull_fn)(struct ndr_pull *, int, void *)) { int i; - uint32 max_count; char *p; p = base; - NDR_CHECK(ndr_pull_uint32(ndr, &max_count)); - if (max_count != count) { - /* maybe we can cope with this? */ - return NT_STATUS_INVALID_PARAMETER; - } if (!(ndr_flags & NDR_SCALARS)) goto buffers; for (i=0;i<count;i++) { NDR_CHECK(pull_fn(ndr, NDR_SCALARS, p)); @@ -244,6 +251,23 @@ done: return NT_STATUS_OK; } +/* + pull a generic array +*/ +NTSTATUS ndr_pull_array(struct ndr_pull *ndr, int ndr_flags, void *base, + size_t elsize, uint32 count, + NTSTATUS (*pull_fn)(struct ndr_pull *, int, void *)) +{ + uint32 max_count; + NDR_CHECK(ndr_pull_uint32(ndr, &max_count)); + if (max_count != count) { + /* maybe we can cope with this? */ + return NT_STATUS_INVALID_PARAMETER; + } + return ndr_pull_const_array(ndr, ndr_flags, base, elsize, count, pull_fn); +} + + /* print a generic array |