diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-17 02:18:11 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-17 02:18:11 +0000 |
commit | 657b4d2abdad5691fc37bafe819f75cc440354b9 (patch) | |
tree | a66c51ef8e39efa62e5b7a5f9e2e227bd3138935 | |
parent | cc5f231e95b2a322a1f1f118b8a3a363a0e4d0cc (diff) | |
download | samba-657b4d2abdad5691fc37bafe819f75cc440354b9.tar.gz samba-657b4d2abdad5691fc37bafe819f75cc440354b9.tar.bz2 samba-657b4d2abdad5691fc37bafe819f75cc440354b9.zip |
nicer method of handling spoolss EnumPrinters
this also handles the return of several printers (an array of relative
subcontexts)
(This used to be commit 060421c7dc9aa611fe4160843a4f76498ab16bf4)
-rw-r--r-- | source4/librpc/idl/spoolss.idl | 17 | ||||
-rw-r--r-- | source4/librpc/ndr/libndr.h | 20 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr.c | 72 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_basic.c | 36 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_dfs.c | 68 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_echo.c | 8 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_lsa.c | 82 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_samr.c | 90 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.c | 137 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss.h | 15 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss_buf.c | 39 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_spoolss_buf.h | 4 | ||||
-rw-r--r-- | source4/torture/rpc/spoolss.c | 34 |
13 files changed, 526 insertions, 96 deletions
diff --git a/source4/librpc/idl/spoolss.idl b/source4/librpc/idl/spoolss.idl index 94c3bf127c..2da15652e5 100644 --- a/source4/librpc/idl/spoolss.idl +++ b/source4/librpc/idl/spoolss.idl @@ -48,14 +48,14 @@ // uint8 private[driverextra]; } spoolss_DeviceMode; - typedef [public] struct { + typedef struct { uint32 flags; [relative] nstring name; [relative] nstring description; [relative] nstring comment; } spoolss_PrinterEnum1; - typedef [public] struct { + typedef struct { [relative] nstring servername; [relative] nstring printername; [relative] nstring sharename; @@ -79,15 +79,18 @@ uint32 averageppm; } spoolss_PrinterEnum2; + typedef [nodiscriminant,public] union { + case(1) spoolss_PrinterEnum1 info1; + case(2) spoolss_PrinterEnum2 info2; + } spoolss_PrinterEnum; + NTSTATUS spoolss_EnumPrinters( [in] uint32 flags, [in] unistr *server, [in] uint32 level, - [in,size_is(offered)] uint8 *buf, - [in] uint32 offered, - [out,subcontext,switch_is(level)] spoolss_PrinterEnum *info, - [out,ref] uint32 *needed, - [out] uint32 returned + [in,out] DATA_BLOB *buffer, + [in,out,ref] uint32 *buf_size, + [out] uint32 count ); /******************/ diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h index f5e64ec872..b826e024f9 100644 --- a/source4/librpc/ndr/libndr.h +++ b/source4/librpc/ndr/libndr.h @@ -23,6 +23,14 @@ */ +/* offset lists are used to allow a push/pull function to find the + start of an encapsulating structure */ +struct ndr_ofs_list { + uint32 offset; + struct ndr_ofs_list *next; +}; + + /* this is the base structure passed to routines that parse MSRPC formatted data @@ -37,14 +45,18 @@ struct ndr_pull { uint32 data_size; uint32 offset; TALLOC_CTX *mem_ctx; + + /* this points at a list of offsets to the structures being processed. + The first element in the list is the current structure */ + struct ndr_ofs_list *ofs_list; }; struct ndr_pull_save { uint32 data_size; uint32 offset; + struct ndr_pull_save *next; }; - /* structure passed to functions that generate NDR formatted data */ struct ndr_push { uint32 flags; /* LIBNDR_FLAG_* */ @@ -53,8 +65,12 @@ struct ndr_push { uint32 offset; TALLOC_CTX *mem_ctx; + /* this points at a list of offsets to the structures being processed. + The first element in the list is the current structure */ + struct ndr_ofs_list *ofs_list; + /* this list is used by the [relative] code to find the offsets */ - struct ndr_push_save *relative_list; + struct ndr_ofs_list *relative_list; }; struct ndr_push_save { diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index fb7c602ce8..97eee70dfe 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -422,6 +422,49 @@ NTSTATUS ndr_pull_subcontext_union_fn(struct ndr_pull *ndr, /* + mark the start of a structure +*/ +NTSTATUS ndr_pull_struct_start(struct ndr_pull *ndr) +{ + struct ndr_ofs_list *ofs; + NDR_ALLOC(ndr, ofs); + ofs->offset = ndr->offset; + ofs->next = ndr->ofs_list; + ndr->ofs_list = ofs; + return NT_STATUS_OK; +} + +/* + mark the end of a structure +*/ +void ndr_pull_struct_end(struct ndr_pull *ndr) +{ + ndr->ofs_list = ndr->ofs_list->next; +} + +/* + mark the start of a structure +*/ +NTSTATUS ndr_push_struct_start(struct ndr_push *ndr) +{ + struct ndr_ofs_list *ofs; + NDR_ALLOC(ndr, ofs); + ofs->offset = ndr->offset; + ofs->next = ndr->ofs_list; + ndr->ofs_list = ofs; + return NT_STATUS_OK; +} + +/* + mark the end of a structure +*/ +void ndr_push_struct_end(struct ndr_push *ndr) +{ + ndr->ofs_list = ndr->ofs_list->next; +} + + +/* pull a relative structure */ NTSTATUS ndr_pull_relative(struct ndr_pull *ndr, const void **buf, size_t size, @@ -438,7 +481,7 @@ NTSTATUS ndr_pull_relative(struct ndr_pull *ndr, const void **buf, size_t size, return NT_STATUS_OK; } ndr_pull_save(ndr, &save); - NDR_CHECK(ndr_pull_set_offset(ndr, ofs)); + NDR_CHECK(ndr_pull_set_offset(ndr, ofs + ndr->ofs_list->offset)); NDR_CHECK(ndr_pull_subcontext(ndr, &ndr2, ndr->data_size - ndr->offset)); if (size == 1) { /* oh what a hack! */ @@ -458,35 +501,34 @@ NTSTATUS ndr_pull_relative(struct ndr_pull *ndr, const void **buf, size_t size, NTSTATUS ndr_push_relative(struct ndr_push *ndr, int ndr_flags, const void *p, NTSTATUS (*fn)(struct ndr_push *, int , const void *)) { - struct ndr_push_save *save; + struct ndr_ofs_list *ofs; if (ndr_flags & NDR_SCALARS) { if (!p) { NDR_CHECK(ndr_push_uint32(ndr, 0)); return NT_STATUS_OK; } - save = talloc(ndr->mem_ctx, sizeof(*save)); - if (!save) return NT_STATUS_NO_MEMORY; + NDR_ALLOC(ndr, ofs); NDR_CHECK(ndr_push_align(ndr, 4)); - ndr_push_save(ndr, save); + ofs->offset = ndr->offset; NDR_CHECK(ndr_push_uint32(ndr, 0xFFFFFFFF)); - save->next = ndr->relative_list; - ndr->relative_list = save; + ofs->next = ndr->relative_list; + ndr->relative_list = ofs; } if (ndr_flags & NDR_BUFFERS) { - struct ndr_push_save save2; + struct ndr_push_save save; if (!p) { return NT_STATUS_OK; } - save = ndr->relative_list; - if (!save) { + ofs = ndr->relative_list; + if (!ofs) { return ndr_push_error(ndr, NDR_ERR_RELATIVE, "Empty relative stack"); } - ndr->relative_list = save->next; + ndr->relative_list = ndr->relative_list->next; NDR_CHECK(ndr_push_align(ndr, 8)); - ndr_push_save(ndr, &save2); - ndr_push_restore(ndr, save); - NDR_CHECK(ndr_push_uint32(ndr, save2.offset)); - ndr_push_restore(ndr, &save2); + ndr_push_save(ndr, &save); + ndr->offset = ofs->offset; + NDR_CHECK(ndr_push_uint32(ndr, save.offset + ndr->ofs_list->offset)); + ndr_push_restore(ndr, &save); NDR_CHECK(fn(ndr, NDR_SCALARS|NDR_BUFFERS, p)); } return NT_STATUS_OK; diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 408d041e3c..2c6a3aac96 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -440,14 +440,18 @@ void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p) } } -void ndr_print_unistr_noterm(struct ndr_print *ndr, const char *name, const char *s) +void ndr_print_unistr(struct ndr_print *ndr, const char *name, const char *s) { - ndr->print(ndr, "%-25s: '%s'", name, s); + if (s) { + ndr->print(ndr, "%-25s: '%s'", name, s); + } else { + ndr->print(ndr, "%-25s: NULL", name); + } } -void ndr_print_unistr(struct ndr_print *ndr, const char *name, const char *s) +void ndr_print_unistr_noterm(struct ndr_print *ndr, const char *name, const char *s) { - ndr->print(ndr, "%-25s: '%s'", name, s); + ndr_print_unistr(ndr, name, s); } void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) @@ -560,3 +564,27 @@ void ndr_print_nstring(struct ndr_print *ndr, const char *name, const char **s) { ndr_print_unistr(ndr, name, *s); } + + +/* + push a DATA_BLOB onto the wire. +*/ +NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, DATA_BLOB blob) +{ + NDR_CHECK(ndr_push_uint32(ndr, blob.length)); + NDR_CHECK(ndr_push_bytes(ndr, blob.data, blob.length)); + return NT_STATUS_OK; +} + +/* + pull a DATA_BLOB from the wire. +*/ +NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) +{ + uint32 length; + NDR_CHECK(ndr_pull_uint32(ndr, &length)); + NDR_PULL_NEED_BYTES(ndr, length); + *blob = data_blob_talloc(ndr->mem_ctx, ndr->data+ndr->offset, length); + ndr->offset += length; + return NT_STATUS_OK; +} diff --git a/source4/librpc/ndr/ndr_dfs.c b/source4/librpc/ndr/ndr_dfs.c index 90f56f911b..f0597a5b7d 100644 --- a/source4/librpc/ndr/ndr_dfs.c +++ b/source4/librpc/ndr/ndr_dfs.c @@ -49,8 +49,10 @@ NTSTATUS ndr_push_dfs_SetInfo(struct ndr_push *ndr, struct dfs_SetInfo *r) NTSTATUS ndr_push_dfs_Info1(struct ndr_push *ndr, int ndr_flags, struct dfs_Info1 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_ptr(ndr, r->path)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->path) { @@ -63,11 +65,13 @@ done: NTSTATUS ndr_push_dfs_Info2(struct ndr_push *ndr, int ndr_flags, struct dfs_Info2 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_ptr(ndr, r->path)); NDR_CHECK(ndr_push_ptr(ndr, r->comment)); NDR_CHECK(ndr_push_uint32(ndr, r->state)); NDR_CHECK(ndr_push_uint32(ndr, r->num_stores)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->path) { @@ -83,10 +87,12 @@ done: NTSTATUS ndr_push_dfs_StorageInfo(struct ndr_push *ndr, int ndr_flags, struct dfs_StorageInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->state)); NDR_CHECK(ndr_push_ptr(ndr, r->server)); NDR_CHECK(ndr_push_ptr(ndr, r->share)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->server) { @@ -102,12 +108,14 @@ done: NTSTATUS ndr_push_dfs_Info3(struct ndr_push *ndr, int ndr_flags, struct dfs_Info3 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_ptr(ndr, r->path)); NDR_CHECK(ndr_push_ptr(ndr, r->comment)); NDR_CHECK(ndr_push_uint32(ndr, r->state)); NDR_CHECK(ndr_push_uint32(ndr, r->num_stores)); NDR_CHECK(ndr_push_ptr(ndr, r->stores)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->path) { @@ -127,6 +135,7 @@ done: NTSTATUS ndr_push_dfs_Info4(struct ndr_push *ndr, int ndr_flags, struct dfs_Info4 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_ptr(ndr, r->path)); NDR_CHECK(ndr_push_ptr(ndr, r->comment)); @@ -135,6 +144,7 @@ NTSTATUS ndr_push_dfs_Info4(struct ndr_push *ndr, int ndr_flags, struct dfs_Info NDR_CHECK(ndr_push_GUID(ndr, NDR_SCALARS, &r->guid)); NDR_CHECK(ndr_push_uint32(ndr, r->num_stores)); NDR_CHECK(ndr_push_ptr(ndr, r->stores)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->path) { @@ -155,8 +165,10 @@ done: NTSTATUS ndr_push_dfs_Info200(struct ndr_push *ndr, int ndr_flags, struct dfs_Info200 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_ptr(ndr, r->dom_root)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->dom_root) { @@ -169,9 +181,11 @@ done: NTSTATUS ndr_push_dfs_Info300(struct ndr_push *ndr, int ndr_flags, struct dfs_Info300 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->flags)); NDR_CHECK(ndr_push_ptr(ndr, r->dom_root)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->dom_root) { @@ -200,9 +214,11 @@ NTSTATUS ndr_push_dfs_GetInfo(struct ndr_push *ndr, struct dfs_GetInfo *r) NTSTATUS ndr_push_dfs_EnumArray1(struct ndr_push *ndr, int ndr_flags, struct dfs_EnumArray1 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->count)); NDR_CHECK(ndr_push_ptr(ndr, r->s)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -216,9 +232,11 @@ done: NTSTATUS ndr_push_dfs_EnumArray2(struct ndr_push *ndr, int ndr_flags, struct dfs_EnumArray2 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->count)); NDR_CHECK(ndr_push_ptr(ndr, r->s)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -232,9 +250,11 @@ done: NTSTATUS ndr_push_dfs_EnumArray3(struct ndr_push *ndr, int ndr_flags, struct dfs_EnumArray3 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->count)); NDR_CHECK(ndr_push_ptr(ndr, r->s)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -248,9 +268,11 @@ done: NTSTATUS ndr_push_dfs_EnumArray4(struct ndr_push *ndr, int ndr_flags, struct dfs_EnumArray4 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->count)); NDR_CHECK(ndr_push_ptr(ndr, r->s)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -264,9 +286,11 @@ done: NTSTATUS ndr_push_dfs_EnumArray200(struct ndr_push *ndr, int ndr_flags, struct dfs_EnumArray200 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->count)); NDR_CHECK(ndr_push_ptr(ndr, r->s)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -280,9 +304,11 @@ done: NTSTATUS ndr_push_dfs_EnumArray300(struct ndr_push *ndr, int ndr_flags, struct dfs_EnumArray300 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->count)); NDR_CHECK(ndr_push_ptr(ndr, r->s)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -296,6 +322,7 @@ done: NTSTATUS ndr_push_dfs_EnumInfo(struct ndr_push *ndr, int ndr_flags, uint16 level, union dfs_EnumInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_uint16(ndr, level)); switch (level) { case 1: @@ -325,6 +352,7 @@ NTSTATUS ndr_push_dfs_EnumInfo(struct ndr_push *ndr, int ndr_flags, uint16 level default: return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (level) { @@ -374,9 +402,11 @@ done: NTSTATUS ndr_push_dfs_EnumStruct(struct ndr_push *ndr, int ndr_flags, struct dfs_EnumStruct *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->level)); NDR_CHECK(ndr_push_dfs_EnumInfo(ndr, NDR_SCALARS, r->level, &r->e)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_push_dfs_EnumInfo(ndr, NDR_BUFFERS, r->level, &r->e)); @@ -435,6 +465,7 @@ NTSTATUS ndr_pull_dfs_SetInfo(struct ndr_pull *ndr, struct dfs_SetInfo *r) NTSTATUS ndr_pull_dfs_Info1(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info1 *r) { uint32 _ptr_path; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_path)); @@ -443,6 +474,7 @@ NTSTATUS ndr_pull_dfs_Info1(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info } else { r->path = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->path) { @@ -456,6 +488,7 @@ NTSTATUS ndr_pull_dfs_Info2(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info { uint32 _ptr_path; uint32 _ptr_comment; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_path)); @@ -472,6 +505,7 @@ NTSTATUS ndr_pull_dfs_Info2(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info } NDR_CHECK(ndr_pull_uint32(ndr, &r->state)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_stores)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->path) { @@ -488,6 +522,7 @@ NTSTATUS ndr_pull_dfs_StorageInfo(struct ndr_pull *ndr, int ndr_flags, struct df { uint32 _ptr_server; uint32 _ptr_share; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->state)); @@ -503,6 +538,7 @@ NTSTATUS ndr_pull_dfs_StorageInfo(struct ndr_pull *ndr, int ndr_flags, struct df } else { r->share = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->server) { @@ -520,6 +556,7 @@ NTSTATUS ndr_pull_dfs_Info3(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info uint32 _ptr_path; uint32 _ptr_comment; uint32 _ptr_stores; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_path)); @@ -542,6 +579,7 @@ NTSTATUS ndr_pull_dfs_Info3(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info } else { r->stores = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->path) { @@ -570,6 +608,7 @@ NTSTATUS ndr_pull_dfs_Info4(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info uint32 _ptr_path; uint32 _ptr_comment; uint32 _ptr_stores; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_path)); @@ -594,6 +633,7 @@ NTSTATUS ndr_pull_dfs_Info4(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info } else { r->stores = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->path) { @@ -621,6 +661,7 @@ done: NTSTATUS ndr_pull_dfs_Info100(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info100 *r) { uint32 _ptr_comment; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_comment)); @@ -629,6 +670,7 @@ NTSTATUS ndr_pull_dfs_Info100(struct ndr_pull *ndr, int ndr_flags, struct dfs_In } else { r->comment = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->comment) { @@ -640,9 +682,11 @@ done: NTSTATUS ndr_pull_dfs_Info101(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info101 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->state)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -651,9 +695,11 @@ done: NTSTATUS ndr_pull_dfs_Info102(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info102 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->timeout)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -663,6 +709,7 @@ done: NTSTATUS ndr_pull_dfs_Info200(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info200 *r) { uint32 _ptr_dom_root; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_dom_root)); @@ -671,6 +718,7 @@ NTSTATUS ndr_pull_dfs_Info200(struct ndr_pull *ndr, int ndr_flags, struct dfs_In } else { r->dom_root = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->dom_root) { @@ -683,6 +731,7 @@ done: NTSTATUS ndr_pull_dfs_Info300(struct ndr_pull *ndr, int ndr_flags, struct dfs_Info300 *r) { uint32 _ptr_dom_root; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->flags)); @@ -692,6 +741,7 @@ NTSTATUS ndr_pull_dfs_Info300(struct ndr_pull *ndr, int ndr_flags, struct dfs_In } else { r->dom_root = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->dom_root) { @@ -704,6 +754,7 @@ done: NTSTATUS ndr_pull_dfs_Info(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union dfs_Info *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_struct_start(ndr)); NDR_CHECK(ndr_pull_uint16(ndr, level)); switch (*level) { case 1: { @@ -799,6 +850,7 @@ NTSTATUS ndr_pull_dfs_Info(struct ndr_pull *ndr, int ndr_flags, uint16 *level, u default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (*level) { @@ -877,6 +929,7 @@ NTSTATUS ndr_pull_dfs_GetInfo(struct ndr_pull *ndr, struct dfs_GetInfo *r) NTSTATUS ndr_pull_dfs_EnumArray1(struct ndr_pull *ndr, int ndr_flags, struct dfs_EnumArray1 *r) { uint32 _ptr_s; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -886,6 +939,7 @@ NTSTATUS ndr_pull_dfs_EnumArray1(struct ndr_pull *ndr, int ndr_flags, struct dfs } else { r->s = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -906,6 +960,7 @@ done: NTSTATUS ndr_pull_dfs_EnumArray2(struct ndr_pull *ndr, int ndr_flags, struct dfs_EnumArray2 *r) { uint32 _ptr_s; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -915,6 +970,7 @@ NTSTATUS ndr_pull_dfs_EnumArray2(struct ndr_pull *ndr, int ndr_flags, struct dfs } else { r->s = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -935,6 +991,7 @@ done: NTSTATUS ndr_pull_dfs_EnumArray3(struct ndr_pull *ndr, int ndr_flags, struct dfs_EnumArray3 *r) { uint32 _ptr_s; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -944,6 +1001,7 @@ NTSTATUS ndr_pull_dfs_EnumArray3(struct ndr_pull *ndr, int ndr_flags, struct dfs } else { r->s = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -964,6 +1022,7 @@ done: NTSTATUS ndr_pull_dfs_EnumArray4(struct ndr_pull *ndr, int ndr_flags, struct dfs_EnumArray4 *r) { uint32 _ptr_s; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -973,6 +1032,7 @@ NTSTATUS ndr_pull_dfs_EnumArray4(struct ndr_pull *ndr, int ndr_flags, struct dfs } else { r->s = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -993,6 +1053,7 @@ done: NTSTATUS ndr_pull_dfs_EnumArray200(struct ndr_pull *ndr, int ndr_flags, struct dfs_EnumArray200 *r) { uint32 _ptr_s; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -1002,6 +1063,7 @@ NTSTATUS ndr_pull_dfs_EnumArray200(struct ndr_pull *ndr, int ndr_flags, struct d } else { r->s = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -1022,6 +1084,7 @@ done: NTSTATUS ndr_pull_dfs_EnumArray300(struct ndr_pull *ndr, int ndr_flags, struct dfs_EnumArray300 *r) { uint32 _ptr_s; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -1031,6 +1094,7 @@ NTSTATUS ndr_pull_dfs_EnumArray300(struct ndr_pull *ndr, int ndr_flags, struct d } else { r->s = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->s) { @@ -1051,6 +1115,7 @@ done: NTSTATUS ndr_pull_dfs_EnumInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union dfs_EnumInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_struct_start(ndr)); NDR_CHECK(ndr_pull_uint16(ndr, level)); switch (*level) { case 1: { @@ -1116,6 +1181,7 @@ NTSTATUS ndr_pull_dfs_EnumInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *leve default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (*level) { @@ -1164,6 +1230,7 @@ done: NTSTATUS ndr_pull_dfs_EnumStruct(struct ndr_pull *ndr, int ndr_flags, struct dfs_EnumStruct *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->level)); @@ -1171,6 +1238,7 @@ NTSTATUS ndr_pull_dfs_EnumStruct(struct ndr_pull *ndr, int ndr_flags, struct dfs NDR_CHECK(ndr_pull_dfs_EnumInfo(ndr, NDR_SCALARS, &_level, &r->e)); if (((NDR_SCALARS) & NDR_SCALARS) && (_level != r->level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in e"); } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; { uint16 _level = r->level; diff --git a/source4/librpc/ndr/ndr_echo.c b/source4/librpc/ndr/ndr_echo.c index d7f131f784..74e55c7c19 100644 --- a/source4/librpc/ndr/ndr_echo.c +++ b/source4/librpc/ndr/ndr_echo.c @@ -93,6 +93,7 @@ NTSTATUS ndr_pull_echo_SourceData(struct ndr_pull *ndr, struct echo_SourceData * NTSTATUS ndr_pull_echo_Enum1(struct ndr_pull *ndr, int ndr_flags, struct echo_Enum1 *r) { uint32 _ptr_count; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_count)); @@ -101,6 +102,7 @@ NTSTATUS ndr_pull_echo_Enum1(struct ndr_pull *ndr, int ndr_flags, struct echo_En } else { r->count = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->count) { @@ -113,6 +115,7 @@ done: NTSTATUS ndr_pull_echo_Enum3(struct ndr_pull *ndr, int ndr_flags, struct echo_Enum3 *r) { uint32 _ptr_count; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_count)); @@ -121,6 +124,7 @@ NTSTATUS ndr_pull_echo_Enum3(struct ndr_pull *ndr, int ndr_flags, struct echo_En } else { r->count = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->count) { @@ -133,6 +137,7 @@ done: NTSTATUS ndr_pull_echo_EnumInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union echo_EnumInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_struct_start(ndr)); NDR_CHECK(ndr_pull_uint16(ndr, level)); switch (*level) { case 1: { @@ -146,6 +151,7 @@ NTSTATUS ndr_pull_echo_EnumInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *lev default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (*level) { @@ -166,6 +172,7 @@ done: NTSTATUS ndr_pull_Struct1(struct ndr_pull *ndr, int ndr_flags, struct Struct1 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->level)); @@ -173,6 +180,7 @@ NTSTATUS ndr_pull_Struct1(struct ndr_pull *ndr, int ndr_flags, struct Struct1 *r NDR_CHECK(ndr_pull_echo_EnumInfo(ndr, NDR_SCALARS, &_level, &r->e)); if (((NDR_SCALARS) & NDR_SCALARS) && (_level != r->level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in e"); } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; { uint16 _level = r->level; diff --git a/source4/librpc/ndr/ndr_lsa.c b/source4/librpc/ndr/ndr_lsa.c index bf27ec3ec5..653274e580 100644 --- a/source4/librpc/ndr/ndr_lsa.c +++ b/source4/librpc/ndr/ndr_lsa.c @@ -19,10 +19,12 @@ NTSTATUS ndr_push_lsa_Delete(struct ndr_push *ndr, struct lsa_Delete *r) NTSTATUS ndr_push_lsa_Name(struct ndr_push *ndr, int ndr_flags, struct lsa_Name *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint16(ndr, 2*strlen_m(r->name))); NDR_CHECK(ndr_push_uint16(ndr, r->name_len)); NDR_CHECK(ndr_push_ptr(ndr, r->name)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->name) { @@ -64,11 +66,13 @@ NTSTATUS ndr_push_lsa_ChangePassword(struct ndr_push *ndr, struct lsa_ChangePass NTSTATUS ndr_push_lsa_QosInfo(struct ndr_push *ndr, int ndr_flags, struct lsa_QosInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->len)); NDR_CHECK(ndr_push_uint16(ndr, r->impersonation_level)); NDR_CHECK(ndr_push_uint8(ndr, r->context_mode)); NDR_CHECK(ndr_push_uint8(ndr, r->effective_only)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -78,6 +82,7 @@ done: NTSTATUS ndr_push_lsa_ObjectAttribute(struct ndr_push *ndr, int ndr_flags, struct lsa_ObjectAttribute *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->len)); NDR_CHECK(ndr_push_ptr(ndr, r->root_dir)); @@ -85,6 +90,7 @@ NTSTATUS ndr_push_lsa_ObjectAttribute(struct ndr_push *ndr, int ndr_flags, struc NDR_CHECK(ndr_push_uint32(ndr, r->attributes)); NDR_CHECK(ndr_push_ptr(ndr, r->sec_desc)); NDR_CHECK(ndr_push_ptr(ndr, r->sec_qos)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->root_dir) { @@ -144,8 +150,10 @@ NTSTATUS ndr_push_lsa_CreateAccount(struct ndr_push *ndr, struct lsa_CreateAccou NTSTATUS ndr_push_lsa_SidPtr(struct ndr_push *ndr, int ndr_flags, struct lsa_SidPtr *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_ptr(ndr, r->sid)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->sid) { @@ -158,9 +166,11 @@ done: NTSTATUS ndr_push_lsa_SidArray(struct ndr_push *ndr, int ndr_flags, struct lsa_SidArray *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->num_sids)); NDR_CHECK(ndr_push_ptr(ndr, r->sids)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->sids) { @@ -198,10 +208,12 @@ NTSTATUS ndr_push_lsa_EnumTrustDom(struct ndr_push *ndr, struct lsa_EnumTrustDom NTSTATUS ndr_push_lsa_TranslatedSid(struct ndr_push *ndr, int ndr_flags, struct lsa_TranslatedSid *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint16(ndr, r->sid_type)); NDR_CHECK(ndr_push_uint32(ndr, r->rid)); NDR_CHECK(ndr_push_uint32(ndr, r->sid_index)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -211,9 +223,11 @@ done: NTSTATUS ndr_push_lsa_TransSidArray(struct ndr_push *ndr, int ndr_flags, struct lsa_TransSidArray *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->count)); NDR_CHECK(ndr_push_ptr(ndr, r->sids)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->sids) { @@ -243,10 +257,12 @@ NTSTATUS ndr_push_lsa_LookupNames(struct ndr_push *ndr, struct lsa_LookupNames * NTSTATUS ndr_push_lsa_TranslatedName(struct ndr_push *ndr, int ndr_flags, struct lsa_TranslatedName *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint16(ndr, r->sid_type)); NDR_CHECK(ndr_push_lsa_Name(ndr, NDR_SCALARS, &r->name)); NDR_CHECK(ndr_push_uint32(ndr, r->sid_index)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_push_lsa_Name(ndr, NDR_BUFFERS, &r->name)); @@ -257,9 +273,11 @@ done: NTSTATUS ndr_push_lsa_TransNameArray(struct ndr_push *ndr, int ndr_flags, struct lsa_TransNameArray *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->count)); NDR_CHECK(ndr_push_ptr(ndr, r->names)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->names) { @@ -299,9 +317,11 @@ NTSTATUS ndr_push_lsa_OpenAccount(struct ndr_push *ndr, struct lsa_OpenAccount * NTSTATUS ndr_push_lsa_LUID(struct ndr_push *ndr, int ndr_flags, struct lsa_LUID *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->low)); NDR_CHECK(ndr_push_uint32(ndr, r->high)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -511,6 +531,7 @@ NTSTATUS ndr_pull_lsa_Delete(struct ndr_pull *ndr, struct lsa_Delete *r) NTSTATUS ndr_pull_lsa_Name(struct ndr_pull *ndr, int ndr_flags, struct lsa_Name *r) { uint32 _ptr_name; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint16(ndr, &r->name_len)); @@ -521,6 +542,7 @@ NTSTATUS ndr_pull_lsa_Name(struct ndr_pull *ndr, int ndr_flags, struct lsa_Name } else { r->name = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->name) { @@ -532,11 +554,13 @@ done: NTSTATUS ndr_pull_lsa_PrivEntry(struct ndr_pull *ndr, int ndr_flags, struct lsa_PrivEntry *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->name)); NDR_CHECK(ndr_pull_uint32(ndr, &r->luid_low)); NDR_CHECK(ndr_pull_uint32(ndr, &r->luid_high)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name)); @@ -547,6 +571,7 @@ done: NTSTATUS ndr_pull_lsa_PrivArray(struct ndr_pull *ndr, int ndr_flags, struct lsa_PrivArray *r) { uint32 _ptr_privs; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -556,6 +581,7 @@ NTSTATUS ndr_pull_lsa_PrivArray(struct ndr_pull *ndr, int ndr_flags, struct lsa_ } else { r->privs = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->privs) { @@ -585,6 +611,7 @@ NTSTATUS ndr_pull_lsa_EnumPrivs(struct ndr_pull *ndr, struct lsa_EnumPrivs *r) NTSTATUS ndr_pull_sec_desc_buf(struct ndr_pull *ndr, int ndr_flags, struct sec_desc_buf *r) { uint32 _ptr_sd; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->size)); @@ -594,6 +621,7 @@ NTSTATUS ndr_pull_sec_desc_buf(struct ndr_pull *ndr, int ndr_flags, struct sec_d } else { r->sd = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->sd) { @@ -644,6 +672,7 @@ NTSTATUS ndr_pull_lsa_OpenPolicy(struct ndr_pull *ndr, struct lsa_OpenPolicy *r) NTSTATUS ndr_pull_lsa_AuditLogInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_AuditLogInfo *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->percent_full)); @@ -653,6 +682,7 @@ NTSTATUS ndr_pull_lsa_AuditLogInfo(struct ndr_pull *ndr, int ndr_flags, struct l NDR_CHECK(ndr_pull_NTTIME(ndr, &r->time_to_shutdown)); NDR_CHECK(ndr_pull_uint32(ndr, &r->next_audit_record)); NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -662,10 +692,12 @@ done: NTSTATUS ndr_pull_lsa_AuditSettings(struct ndr_pull *ndr, int ndr_flags, struct lsa_AuditSettings *r) { uint32 _conformant_size; + NDR_CHECK(ndr_pull_struct_start(ndr)); NDR_CHECK(ndr_pull_uint32(ndr, &_conformant_size)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->count > _conformant_size) { @@ -680,6 +712,7 @@ done: NTSTATUS ndr_pull_lsa_AuditEventsInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_AuditEventsInfo *r) { uint32 _ptr_settings; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->auditing_mode)); @@ -689,6 +722,7 @@ NTSTATUS ndr_pull_lsa_AuditEventsInfo(struct ndr_pull *ndr, int ndr_flags, struc } else { r->settings = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->settings) { @@ -701,6 +735,7 @@ done: NTSTATUS ndr_pull_lsa_DomainInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_DomainInfo *r) { uint32 _ptr_sid; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->name)); @@ -710,6 +745,7 @@ NTSTATUS ndr_pull_lsa_DomainInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa } else { r->sid = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name)); @@ -722,9 +758,11 @@ done: NTSTATUS ndr_pull_lsa_PDAccountInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_PDAccountInfo *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->name)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name)); @@ -734,9 +772,11 @@ done: NTSTATUS ndr_pull_lsa_ServerRole(struct ndr_pull *ndr, int ndr_flags, struct lsa_ServerRole *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint16(ndr, &r->role)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -745,10 +785,12 @@ done: NTSTATUS ndr_pull_lsa_ReplicaSourceInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_ReplicaSourceInfo *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->source)); NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->account)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->source)); @@ -759,6 +801,7 @@ done: NTSTATUS ndr_pull_lsa_DefaultQuotaInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_DefaultQuotaInfo *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_uint32(ndr, &r->paged_pool)); @@ -767,6 +810,7 @@ NTSTATUS ndr_pull_lsa_DefaultQuotaInfo(struct ndr_pull *ndr, int ndr_flags, stru NDR_CHECK(ndr_pull_uint32(ndr, &r->max_wss)); NDR_CHECK(ndr_pull_uint32(ndr, &r->pagefile)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->unknown)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -775,10 +819,12 @@ done: NTSTATUS ndr_pull_lsa_ModificationInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_ModificationInfo *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->modified_id)); NDR_CHECK(ndr_pull_NTTIME(ndr, &r->db_create_time)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -787,9 +833,11 @@ done: NTSTATUS ndr_pull_lsa_AuditFullSetInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_AuditFullSetInfo *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->shutdown_on_full)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -798,10 +846,12 @@ done: NTSTATUS ndr_pull_lsa_AuditFullQueryInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_AuditFullQueryInfo *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->shutdown_on_full)); NDR_CHECK(ndr_pull_uint32(ndr, &r->log_is_full)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -811,6 +861,7 @@ done: NTSTATUS ndr_pull_lsa_DnsDomainInfo(struct ndr_pull *ndr, int ndr_flags, struct lsa_DnsDomainInfo *r) { uint32 _ptr_sid; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->name)); @@ -823,6 +874,7 @@ NTSTATUS ndr_pull_lsa_DnsDomainInfo(struct ndr_pull *ndr, int ndr_flags, struct } else { r->sid = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name)); @@ -839,6 +891,7 @@ done: NTSTATUS ndr_pull_lsa_PolicyInformation(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union lsa_PolicyInformation *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_struct_start(ndr)); NDR_CHECK(ndr_pull_uint16(ndr, level)); switch (*level) { case 1: { @@ -892,6 +945,7 @@ NTSTATUS ndr_pull_lsa_PolicyInformation(struct ndr_pull *ndr, int ndr_flags, uin default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (*level) { @@ -994,6 +1048,7 @@ NTSTATUS ndr_pull_lsa_CreateAccount(struct ndr_pull *ndr, struct lsa_CreateAccou NTSTATUS ndr_pull_lsa_SidPtr(struct ndr_pull *ndr, int ndr_flags, struct lsa_SidPtr *r) { uint32 _ptr_sid; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_sid)); @@ -1002,6 +1057,7 @@ NTSTATUS ndr_pull_lsa_SidPtr(struct ndr_pull *ndr, int ndr_flags, struct lsa_Sid } else { r->sid = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->sid) { @@ -1014,6 +1070,7 @@ done: NTSTATUS ndr_pull_lsa_SidArray(struct ndr_pull *ndr, int ndr_flags, struct lsa_SidArray *r) { uint32 _ptr_sids; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_sids)); @@ -1023,6 +1080,7 @@ NTSTATUS ndr_pull_lsa_SidArray(struct ndr_pull *ndr, int ndr_flags, struct lsa_S } else { r->sids = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->sids) { @@ -1059,6 +1117,7 @@ NTSTATUS ndr_pull_lsa_CreateTrustDom(struct ndr_pull *ndr, struct lsa_CreateTrus NTSTATUS ndr_pull_lsa_DomainInformation(struct ndr_pull *ndr, int ndr_flags, struct lsa_DomainInformation *r) { uint32 _ptr_sid; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->name)); @@ -1068,6 +1127,7 @@ NTSTATUS ndr_pull_lsa_DomainInformation(struct ndr_pull *ndr, int ndr_flags, str } else { r->sid = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name)); @@ -1081,6 +1141,7 @@ done: NTSTATUS ndr_pull_lsa_DomainList(struct ndr_pull *ndr, int ndr_flags, struct lsa_DomainList *r) { uint32 _ptr_domains; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -1090,6 +1151,7 @@ NTSTATUS ndr_pull_lsa_DomainList(struct ndr_pull *ndr, int ndr_flags, struct lsa } else { r->domains = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->domains) { @@ -1118,11 +1180,13 @@ NTSTATUS ndr_pull_lsa_EnumTrustDom(struct ndr_pull *ndr, struct lsa_EnumTrustDom NTSTATUS ndr_pull_lsa_TranslatedSid(struct ndr_pull *ndr, int ndr_flags, struct lsa_TranslatedSid *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint16(ndr, &r->sid_type)); NDR_CHECK(ndr_pull_uint32(ndr, &r->rid)); NDR_CHECK(ndr_pull_uint32(ndr, &r->sid_index)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -1132,6 +1196,7 @@ done: NTSTATUS ndr_pull_lsa_TransSidArray(struct ndr_pull *ndr, int ndr_flags, struct lsa_TransSidArray *r) { uint32 _ptr_sids; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -1141,6 +1206,7 @@ NTSTATUS ndr_pull_lsa_TransSidArray(struct ndr_pull *ndr, int ndr_flags, struct } else { r->sids = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->sids) { @@ -1161,6 +1227,7 @@ done: NTSTATUS ndr_pull_lsa_TrustInformation(struct ndr_pull *ndr, int ndr_flags, struct lsa_TrustInformation *r) { uint32 _ptr_sid; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->name)); @@ -1170,6 +1237,7 @@ NTSTATUS ndr_pull_lsa_TrustInformation(struct ndr_pull *ndr, int ndr_flags, stru } else { r->sid = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name)); @@ -1183,6 +1251,7 @@ done: NTSTATUS ndr_pull_lsa_RefDomainList(struct ndr_pull *ndr, int ndr_flags, struct lsa_RefDomainList *r) { uint32 _ptr_domains; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -1193,6 +1262,7 @@ NTSTATUS ndr_pull_lsa_RefDomainList(struct ndr_pull *ndr, int ndr_flags, struct r->domains = NULL; } NDR_CHECK(ndr_pull_uint32(ndr, &r->max_count)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->domains) { @@ -1231,11 +1301,13 @@ NTSTATUS ndr_pull_lsa_LookupNames(struct ndr_pull *ndr, struct lsa_LookupNames * NTSTATUS ndr_pull_lsa_TranslatedName(struct ndr_pull *ndr, int ndr_flags, struct lsa_TranslatedName *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint16(ndr, &r->sid_type)); NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_SCALARS, &r->name)); NDR_CHECK(ndr_pull_uint32(ndr, &r->sid_index)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_lsa_Name(ndr, NDR_BUFFERS, &r->name)); @@ -1246,6 +1318,7 @@ done: NTSTATUS ndr_pull_lsa_TransNameArray(struct ndr_pull *ndr, int ndr_flags, struct lsa_TransNameArray *r) { uint32 _ptr_names; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -1255,6 +1328,7 @@ NTSTATUS ndr_pull_lsa_TransNameArray(struct ndr_pull *ndr, int ndr_flags, struct } else { r->names = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->names) { @@ -1308,10 +1382,12 @@ NTSTATUS ndr_pull_lsa_OpenAccount(struct ndr_pull *ndr, struct lsa_OpenAccount * NTSTATUS ndr_pull_lsa_LUID(struct ndr_pull *ndr, int ndr_flags, struct lsa_LUID *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->low)); NDR_CHECK(ndr_pull_uint32(ndr, &r->high)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -1320,10 +1396,12 @@ done: NTSTATUS ndr_pull_lsa_LUIDAttribute(struct ndr_pull *ndr, int ndr_flags, struct lsa_LUIDAttribute *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_lsa_LUID(ndr, NDR_SCALARS, &r->luid)); NDR_CHECK(ndr_pull_uint32(ndr, &r->attribute)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_lsa_LUID(ndr, NDR_BUFFERS, &r->luid)); @@ -1334,11 +1412,13 @@ done: NTSTATUS ndr_pull_lsa_PrivilegeSet(struct ndr_pull *ndr, int ndr_flags, struct lsa_PrivilegeSet *r) { uint32 _conformant_size; + NDR_CHECK(ndr_pull_struct_start(ndr)); NDR_CHECK(ndr_pull_uint32(ndr, &_conformant_size)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->count > _conformant_size) { @@ -1499,6 +1579,7 @@ NTSTATUS ndr_pull_ENUMACCTWITHRIGHT(struct ndr_pull *ndr, struct ENUMACCTWITHRIG NTSTATUS ndr_pull_lsa_RightSet(struct ndr_pull *ndr, int ndr_flags, struct lsa_RightSet *r) { uint32 _ptr_names; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -1508,6 +1589,7 @@ NTSTATUS ndr_pull_lsa_RightSet(struct ndr_pull *ndr, int ndr_flags, struct lsa_R } else { r->names = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->names) { diff --git a/source4/librpc/ndr/ndr_samr.c b/source4/librpc/ndr/ndr_samr.c index ef5206bc08..a3786117b1 100644 --- a/source4/librpc/ndr/ndr_samr.c +++ b/source4/librpc/ndr/ndr_samr.c @@ -41,10 +41,12 @@ NTSTATUS ndr_push_samr_Shutdown(struct ndr_push *ndr, struct samr_Shutdown *r) NTSTATUS ndr_push_samr_Name(struct ndr_push *ndr, int ndr_flags, struct samr_Name *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint16(ndr, 2*strlen_m(r->name))); NDR_CHECK(ndr_push_uint16(ndr, r->name_len)); NDR_CHECK(ndr_push_ptr(ndr, r->name)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->name) { @@ -513,6 +515,7 @@ NTSTATUS ndr_pull_samr_Shutdown(struct ndr_pull *ndr, struct samr_Shutdown *r) NTSTATUS ndr_pull_samr_Name(struct ndr_pull *ndr, int ndr_flags, struct samr_Name *r) { uint32 _ptr_name; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint16(ndr, &r->name_len)); @@ -523,6 +526,7 @@ NTSTATUS ndr_pull_samr_Name(struct ndr_pull *ndr, int ndr_flags, struct samr_Nam } else { r->name = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->name) { @@ -551,10 +555,12 @@ NTSTATUS ndr_pull_samr_LookupDomain(struct ndr_pull *ndr, struct samr_LookupDoma NTSTATUS ndr_pull_samr_SamEntry(struct ndr_pull *ndr, int ndr_flags, struct samr_SamEntry *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->idx)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->name)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->name)); @@ -565,6 +571,7 @@ done: NTSTATUS ndr_pull_samr_SamArray(struct ndr_pull *ndr, int ndr_flags, struct samr_SamArray *r) { uint32 _ptr_entries; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); @@ -574,6 +581,7 @@ NTSTATUS ndr_pull_samr_SamArray(struct ndr_pull *ndr, int ndr_flags, struct samr } else { r->entries = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->entries) { @@ -620,6 +628,7 @@ NTSTATUS ndr_pull_samr_OpenDomain(struct ndr_pull *ndr, struct samr_OpenDomain * NTSTATUS ndr_pull_samr_DomInfo1(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo1 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint16(ndr, &r->min_length_password)); @@ -627,6 +636,7 @@ NTSTATUS ndr_pull_samr_DomInfo1(struct ndr_pull *ndr, int ndr_flags, struct samr NDR_CHECK(ndr_pull_uint32(ndr, &r->flag)); NDR_CHECK(ndr_pull_NTTIME(ndr, &r->expire)); NDR_CHECK(ndr_pull_NTTIME(ndr, &r->min_passwordage)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -635,6 +645,7 @@ done: NTSTATUS ndr_pull_samr_DomInfo2(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo2 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->force_logoff_time)); @@ -648,6 +659,7 @@ NTSTATUS ndr_pull_samr_DomInfo2(struct ndr_pull *ndr, int ndr_flags, struct samr NDR_CHECK(ndr_pull_uint32(ndr, &r->num_users)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_groups)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_aliases)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->unknown1)); @@ -659,9 +671,11 @@ done: NTSTATUS ndr_pull_samr_DomInfo3(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo3 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->force_logoff_time)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -670,9 +684,11 @@ done: NTSTATUS ndr_pull_samr_DomInfo4(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo4 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->unknown)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->unknown)); @@ -682,9 +698,11 @@ done: NTSTATUS ndr_pull_samr_DomInfo5(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo5 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->domain)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->domain)); @@ -694,9 +712,11 @@ done: NTSTATUS ndr_pull_samr_DomInfo6(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo6 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->primary)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->primary)); @@ -706,9 +726,11 @@ done: NTSTATUS ndr_pull_samr_DomInfo7(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo7 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->role)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -717,10 +739,12 @@ done: NTSTATUS ndr_pull_samr_DomInfo8(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo8 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->sequence_num)); NDR_CHECK(ndr_pull_NTTIME(ndr, &r->last_xxx_time)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -729,9 +753,11 @@ done: NTSTATUS ndr_pull_samr_DomInfo9(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo9 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -740,6 +766,7 @@ done: NTSTATUS ndr_pull_samr_DomInfo11(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo11 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->force_logoff_time)); @@ -756,6 +783,7 @@ NTSTATUS ndr_pull_samr_DomInfo11(struct ndr_pull *ndr, int ndr_flags, struct sam NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->lockout_duration)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->lockout_window)); NDR_CHECK(ndr_pull_uint16(ndr, &r->lockout_threshold)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->unknown1)); @@ -767,11 +795,13 @@ done: NTSTATUS ndr_pull_samr_DomInfo12(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo12 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->lockout_duration)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->lockout_window)); NDR_CHECK(ndr_pull_uint16(ndr, &r->lockout_threshold)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -780,12 +810,14 @@ done: NTSTATUS ndr_pull_samr_DomInfo13(struct ndr_pull *ndr, int ndr_flags, struct samr_DomInfo13 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->sequence_num)); NDR_CHECK(ndr_pull_NTTIME(ndr, &r->last_xxx_time)); NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown1)); NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown2)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -795,6 +827,7 @@ done: NTSTATUS ndr_pull_samr_DomainInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union samr_DomainInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_struct_start(ndr)); NDR_CHECK(ndr_pull_uint16(ndr, level)); switch (*level) { case 1: { @@ -848,6 +881,7 @@ NTSTATUS ndr_pull_samr_DomainInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *l default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (*level) { @@ -1042,12 +1076,14 @@ NTSTATUS ndr_pull_samr_OpenGroup(struct ndr_pull *ndr, struct samr_OpenGroup *r) NTSTATUS ndr_pull_samr_GroupInfoAll(struct ndr_pull *ndr, int ndr_flags, struct samr_GroupInfoAll *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->name)); NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_members)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->description)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->name)); @@ -1058,9 +1094,11 @@ done: NTSTATUS ndr_pull_samr_GroupInfoName(struct ndr_pull *ndr, int ndr_flags, struct samr_GroupInfoName *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->Name)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->Name)); @@ -1070,9 +1108,11 @@ done: NTSTATUS ndr_pull_samr_GroupInfoX(struct ndr_pull *ndr, int ndr_flags, struct samr_GroupInfoX *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -1081,9 +1121,11 @@ done: NTSTATUS ndr_pull_samr_GroupInfoDesciption(struct ndr_pull *ndr, int ndr_flags, struct samr_GroupInfoDesciption *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->description)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->description)); @@ -1094,6 +1136,7 @@ done: NTSTATUS ndr_pull_samr_GroupInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union samr_GroupInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_struct_start(ndr)); NDR_CHECK(ndr_pull_uint16(ndr, level)); switch (*level) { case 1: { @@ -1115,6 +1158,7 @@ NTSTATUS ndr_pull_samr_GroupInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *le default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (*level) { @@ -1213,11 +1257,13 @@ NTSTATUS ndr_pull_samr_OpenAlias(struct ndr_pull *ndr, struct samr_OpenAlias *r) NTSTATUS ndr_pull_samr_AliasInfoAll(struct ndr_pull *ndr, int ndr_flags, struct samr_AliasInfoAll *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->name)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_members)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->description)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->name)); @@ -1228,9 +1274,11 @@ done: NTSTATUS ndr_pull_samr_AliasInfoName(struct ndr_pull *ndr, int ndr_flags, struct samr_AliasInfoName *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->name)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->name)); @@ -1240,9 +1288,11 @@ done: NTSTATUS ndr_pull_samr_AliasInfoDescription(struct ndr_pull *ndr, int ndr_flags, struct samr_AliasInfoDescription *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->description)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->description)); @@ -1253,6 +1303,7 @@ done: NTSTATUS ndr_pull_samr_AliasInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union samr_AliasInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_struct_start(ndr)); NDR_CHECK(ndr_pull_uint16(ndr, level)); switch (*level) { case 1: { @@ -1270,6 +1321,7 @@ NTSTATUS ndr_pull_samr_AliasInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *le default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (*level) { @@ -1364,6 +1416,7 @@ NTSTATUS ndr_pull_samr_DELETE_DOM_USER(struct ndr_pull *ndr, struct samr_DELETE_ NTSTATUS ndr_pull_samr_UserInfo1(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo1 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->username)); @@ -1371,6 +1424,7 @@ NTSTATUS ndr_pull_samr_UserInfo1(struct ndr_pull *ndr, int ndr_flags, struct sam NDR_CHECK(ndr_pull_uint32(ndr, &r->primary_group_rid)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->description)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->comment)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->username)); @@ -1383,6 +1437,7 @@ done: NTSTATUS ndr_pull_samr_UserInfo2(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo2 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->comment)); @@ -1390,6 +1445,7 @@ NTSTATUS ndr_pull_samr_UserInfo2(struct ndr_pull *ndr, int ndr_flags, struct sam NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown2)); NDR_CHECK(ndr_pull_uint16(ndr, &r->country_code)); NDR_CHECK(ndr_pull_uint16(ndr, &r->code_page)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->comment)); @@ -1400,6 +1456,7 @@ done: NTSTATUS ndr_pull_samr_UserInfo3(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo3 *r) { uint32 _ptr_logon_hours; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->username)); @@ -1426,6 +1483,7 @@ NTSTATUS ndr_pull_samr_UserInfo3(struct ndr_pull *ndr, int ndr_flags, struct sam NDR_CHECK(ndr_pull_uint16(ndr, &r->bad_pwd_count)); NDR_CHECK(ndr_pull_uint16(ndr, &r->num_logons)); NDR_CHECK(ndr_pull_uint32(ndr, &r->acct_flags)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->username)); @@ -1458,6 +1516,7 @@ done: NTSTATUS ndr_pull_samr_UserInfo4(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo4 *r) { uint32 _ptr_logon_hours; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->units_per_week)); @@ -1467,6 +1526,7 @@ NTSTATUS ndr_pull_samr_UserInfo4(struct ndr_pull *ndr, int ndr_flags, struct sam } else { r->logon_hours = NULL; } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->logon_hours) { @@ -1492,6 +1552,7 @@ done: NTSTATUS ndr_pull_samr_UserInfo5(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo5 *r) { uint32 _ptr_logon_hours; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->username)); @@ -1517,6 +1578,7 @@ NTSTATUS ndr_pull_samr_UserInfo5(struct ndr_pull *ndr, int ndr_flags, struct sam NDR_CHECK(ndr_pull_NTTIME(ndr, &r->last_pwd_change)); NDR_CHECK(ndr_pull_NTTIME(ndr, &r->acct_expiry)); NDR_CHECK(ndr_pull_uint32(ndr, &r->acct_flags)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->username)); @@ -1549,10 +1611,12 @@ done: NTSTATUS ndr_pull_samr_UserInfo6(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo6 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->username)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->full_name)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->username)); @@ -1563,9 +1627,11 @@ done: NTSTATUS ndr_pull_samr_UserInfo7(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo7 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->username)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->username)); @@ -1575,9 +1641,11 @@ done: NTSTATUS ndr_pull_samr_UserInfo8(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo8 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->full_name)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->full_name)); @@ -1587,9 +1655,11 @@ done: NTSTATUS ndr_pull_samr_UserInfo9(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo9 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->PrimaryGroupRid)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -1598,10 +1668,12 @@ done: NTSTATUS ndr_pull_samr_UserInfo10(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo10 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->home_dir)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->home_drive)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->home_dir)); @@ -1612,9 +1684,11 @@ done: NTSTATUS ndr_pull_samr_UserInfo11(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo11 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->logon_script)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->logon_script)); @@ -1624,9 +1698,11 @@ done: NTSTATUS ndr_pull_samr_UserInfo12(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo12 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->profile)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->profile)); @@ -1636,9 +1712,11 @@ done: NTSTATUS ndr_pull_samr_UserInfo13(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo13 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->descriptiom)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->descriptiom)); @@ -1648,9 +1726,11 @@ done: NTSTATUS ndr_pull_samr_UserInfo14(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo14 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->workstations)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->workstations)); @@ -1660,9 +1740,11 @@ done: NTSTATUS ndr_pull_samr_UserInfo16(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo16 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->acct_flags)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -1671,9 +1753,11 @@ done: NTSTATUS ndr_pull_samr_UserInfo17(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo17 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_NTTIME(ndr, &r->acct_expiry)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -1682,9 +1766,11 @@ done: NTSTATUS ndr_pull_samr_UserInfo20(struct ndr_pull *ndr, int ndr_flags, struct samr_UserInfo20 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->callback)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->callback)); @@ -1696,6 +1782,7 @@ NTSTATUS ndr_pull_samr_UserInfo21(struct ndr_pull *ndr, int ndr_flags, struct sa { uint32 _ptr_buffer; uint32 _ptr_logon_hours; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_NTTIME(ndr, &r->last_logon)); @@ -1743,6 +1830,7 @@ NTSTATUS ndr_pull_samr_UserInfo21(struct ndr_pull *ndr, int ndr_flags, struct sa NDR_CHECK(ndr_pull_uint8(ndr, &r->lm_pwd_set)); NDR_CHECK(ndr_pull_uint8(ndr, &r->expired_flag)); NDR_CHECK(ndr_pull_uint8(ndr, &r->unknown4)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->username)); @@ -1792,6 +1880,7 @@ done: NTSTATUS ndr_pull_samr_UserInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union samr_UserInfo *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_struct_start(ndr)); NDR_CHECK(ndr_pull_uint16(ndr, level)); switch (*level) { case 1: { @@ -1869,6 +1958,7 @@ NTSTATUS ndr_pull_samr_UserInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *lev default: return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (*level) { diff --git a/source4/librpc/ndr/ndr_spoolss.c b/source4/librpc/ndr/ndr_spoolss.c index 0ddd9b2ac8..0b6e088e8f 100644 --- a/source4/librpc/ndr/ndr_spoolss.c +++ b/source4/librpc/ndr/ndr_spoolss.c @@ -5,6 +5,7 @@ NTSTATUS ndr_push_spoolss_DeviceMode(struct ndr_push *ndr, int ndr_flags, struct spoolss_DeviceMode *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_nstring(ndr, NDR_SCALARS, &r->devicename)); NDR_CHECK(ndr_push_uint16(ndr, r->specversion)); @@ -40,6 +41,7 @@ NTSTATUS ndr_push_spoolss_DeviceMode(struct ndr_push *ndr, int ndr_flags, struct NDR_CHECK(ndr_push_uint32(ndr, r->reserved2)); NDR_CHECK(ndr_push_uint32(ndr, r->panningwidth)); NDR_CHECK(ndr_push_uint32(ndr, r->panningheight)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_push_nstring(ndr, NDR_BUFFERS, &r->devicename)); @@ -51,11 +53,13 @@ done: NTSTATUS ndr_push_spoolss_PrinterEnum1(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterEnum1 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->flags)); NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->name, (ndr_push_const_fn_t) ndr_push_nstring)); NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->description, (ndr_push_const_fn_t) ndr_push_nstring)); NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->comment, (ndr_push_const_fn_t) ndr_push_nstring)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, &r->name, (ndr_push_const_fn_t) ndr_push_nstring)); @@ -68,6 +72,7 @@ done: NTSTATUS ndr_push_spoolss_PrinterEnum2(struct ndr_push *ndr, int ndr_flags, struct spoolss_PrinterEnum2 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->servername, (ndr_push_const_fn_t) ndr_push_nstring)); NDR_CHECK(ndr_push_relative(ndr, NDR_SCALARS, r->printername, (ndr_push_const_fn_t) ndr_push_nstring)); @@ -90,6 +95,7 @@ NTSTATUS ndr_push_spoolss_PrinterEnum2(struct ndr_push *ndr, int ndr_flags, stru NDR_CHECK(ndr_push_uint32(ndr, r->status)); NDR_CHECK(ndr_push_uint32(ndr, r->cjobs)); NDR_CHECK(ndr_push_uint32(ndr, r->averageppm)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_push_relative(ndr, NDR_BUFFERS, &r->servername, (ndr_push_const_fn_t) ndr_push_nstring)); @@ -113,6 +119,41 @@ done: return NT_STATUS_OK; } +NTSTATUS ndr_push_spoolss_PrinterEnum(struct ndr_push *ndr, int ndr_flags, uint16 level, union spoolss_PrinterEnum *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); + switch (level) { + case 1: + NDR_CHECK(ndr_push_spoolss_PrinterEnum1(ndr, NDR_SCALARS, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_push_spoolss_PrinterEnum2(ndr, NDR_SCALARS, &r->info2)); + break; + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } + ndr_push_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + switch (level) { + case 1: + NDR_CHECK(ndr_push_spoolss_PrinterEnum1(ndr, ndr_flags, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_push_spoolss_PrinterEnum2(ndr, ndr_flags, &r->info2)); + break; + + default: + return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); + } +done: + return NT_STATUS_OK; +} + NTSTATUS ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, struct spoolss_EnumPrinters *r) { NDR_CHECK(ndr_push_uint32(ndr, r->in.flags)); @@ -121,12 +162,11 @@ NTSTATUS ndr_push_spoolss_EnumPrinters(struct ndr_push *ndr, struct spoolss_Enum NDR_CHECK(ndr_push_unistr(ndr, r->in.server)); } NDR_CHECK(ndr_push_uint32(ndr, r->in.level)); - NDR_CHECK(ndr_push_ptr(ndr, r->in.buf)); - if (r->in.buf) { - NDR_CHECK(ndr_push_uint32(ndr, r->in.offered)); - NDR_CHECK(ndr_push_array_uint8(ndr, r->in.buf, r->in.offered)); + NDR_CHECK(ndr_push_ptr(ndr, r->in.buffer)); + if (r->in.buffer) { + NDR_CHECK(ndr_push_DATA_BLOB(ndr, *r->in.buffer)); } - NDR_CHECK(ndr_push_uint32(ndr, r->in.offered)); + NDR_CHECK(ndr_push_uint32(ndr, *r->in.buf_size)); return NT_STATUS_OK; } @@ -561,8 +601,10 @@ NTSTATUS ndr_push_spoolss_44(struct ndr_push *ndr, struct spoolss_44 *r) NTSTATUS ndr_push_spoolss_Devmode(struct ndr_push *ndr, int ndr_flags, struct spoolss_Devmode *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->foo)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -572,9 +614,11 @@ done: NTSTATUS ndr_push_spoolss_DevmodeContainer(struct ndr_push *ndr, int ndr_flags, struct spoolss_DevmodeContainer *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->size)); NDR_CHECK(ndr_push_ptr(ndr, r->devmode)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->devmode) { @@ -587,6 +631,7 @@ done: NTSTATUS ndr_push_spoolss_UserLevel1(struct ndr_push *ndr, int ndr_flags, struct spoolss_UserLevel1 *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_align(ndr, 4)); NDR_CHECK(ndr_push_uint32(ndr, r->size)); NDR_CHECK(ndr_push_ptr(ndr, r->client)); @@ -595,6 +640,7 @@ NTSTATUS ndr_push_spoolss_UserLevel1(struct ndr_push *ndr, int ndr_flags, struct NDR_CHECK(ndr_push_uint32(ndr, r->major)); NDR_CHECK(ndr_push_uint32(ndr, r->minor)); NDR_CHECK(ndr_push_uint32(ndr, r->processor)); + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; if (r->client) { @@ -610,6 +656,7 @@ done: NTSTATUS ndr_push_spoolss_UserLevel(struct ndr_push *ndr, int ndr_flags, uint16 level, union spoolss_UserLevel *r) { if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_struct_start(ndr)); NDR_CHECK(ndr_push_uint16(ndr, level)); switch (level) { case 1: @@ -619,6 +666,7 @@ NTSTATUS ndr_push_spoolss_UserLevel(struct ndr_push *ndr, int ndr_flags, uint16 default: return ndr_push_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", level); } + ndr_push_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; switch (level) { @@ -815,6 +863,7 @@ NTSTATUS ndr_push_spoolss_5f(struct ndr_push *ndr, struct spoolss_5f *r) NTSTATUS ndr_pull_spoolss_DeviceMode(struct ndr_pull *ndr, int ndr_flags, struct spoolss_DeviceMode *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_nstring(ndr, NDR_SCALARS, &r->devicename)); @@ -851,6 +900,7 @@ NTSTATUS ndr_pull_spoolss_DeviceMode(struct ndr_pull *ndr, int ndr_flags, struct NDR_CHECK(ndr_pull_uint32(ndr, &r->reserved2)); NDR_CHECK(ndr_pull_uint32(ndr, &r->panningwidth)); NDR_CHECK(ndr_pull_uint32(ndr, &r->panningheight)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; NDR_CHECK(ndr_pull_nstring(ndr, NDR_BUFFERS, &r->devicename)); @@ -861,12 +911,14 @@ done: NTSTATUS ndr_pull_spoolss_PrinterEnum1(struct ndr_pull *ndr, int ndr_flags, struct spoolss_PrinterEnum1 *r) { + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_uint32(ndr, &r->flags)); NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->name, sizeof(*r->name), (ndr_pull_flags_fn_t)ndr_pull_nstring)); NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->description, sizeof(*r->description), (ndr_pull_flags_fn_t)ndr_pull_nstring)); NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->comment, sizeof(*r->comment), (ndr_pull_flags_fn_t)ndr_pull_nstring)); + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; done: @@ -877,6 +929,7 @@ NTSTATUS ndr_pull_spoolss_PrinterEnum2(struct ndr_pull *ndr, int ndr_flags, stru { uint32 _ptr_devmode; uint32 _ptr_secdesc; + NDR_CHECK(ndr_pull_struct_start(ndr)); if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); NDR_CHECK(ndr_pull_relative(ndr, (const void **)&r->servername, sizeof(*r->servername), (ndr_pull_flags_fn_t)ndr_pull_nstring)); @@ -900,29 +953,62 @@ NTSTATUS ndr_pull_spoolss_PrinterEnum2(struct ndr_pull *ndr, int ndr_flags, stru NDR_CHECK(ndr_pull_uint32(ndr, &r->status)); NDR_CHECK(ndr_pull_uint32(ndr, &r->cjobs)); NDR_CHECK(ndr_pull_uint32(ndr, &r->averageppm)); + ndr_pull_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_spoolss_PrinterEnum(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union spoolss_PrinterEnum *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_struct_start(ndr)); + switch (*level) { + case 1: { + NDR_CHECK(ndr_pull_spoolss_PrinterEnum1(ndr, NDR_SCALARS, &r->info1)); + break; } + + case 2: { + NDR_CHECK(ndr_pull_spoolss_PrinterEnum2(ndr, NDR_SCALARS, &r->info2)); + break; } + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); + } + ndr_pull_struct_end(ndr); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; + switch (*level) { + case 1: + NDR_CHECK(ndr_pull_spoolss_PrinterEnum1(ndr, NDR_BUFFERS, &r->info1)); + break; + + case 2: + NDR_CHECK(ndr_pull_spoolss_PrinterEnum2(ndr, NDR_BUFFERS, &r->info2)); + break; + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); + } done: return NT_STATUS_OK; } NTSTATUS ndr_pull_spoolss_EnumPrinters(struct ndr_pull *ndr, struct spoolss_EnumPrinters *r) { - uint32 _ptr_info; - NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_info)); - if (_ptr_info) { - NDR_ALLOC(ndr, r->out.info); + uint32 _ptr_buffer; + NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_buffer)); + if (_ptr_buffer) { + NDR_ALLOC(ndr, r->out.buffer); } else { - r->out.info = NULL; - } - if (r->out.info) { - { uint16 _level = r->in.level; - NDR_CHECK(ndr_pull_subcontext_union_fn(ndr, &_level, r->out.info, (ndr_pull_union_fn_t) ndr_pull_spoolss_PrinterEnum)); - if (((NDR_SCALARS|NDR_BUFFERS) & NDR_SCALARS) && (_level != r->in.level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in info"); + r->out.buffer = NULL; } + if (r->out.buffer) { + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, r->out.buffer)); } - NDR_CHECK(ndr_pull_uint32(ndr, r->out.needed)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->out.returned)); + NDR_CHECK(ndr_pull_uint32(ndr, r->out.buf_size)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->out.count)); NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); return NT_STATUS_OK; @@ -1724,6 +1810,23 @@ void ndr_print_spoolss_PrinterEnum2(struct ndr_print *ndr, const char *name, str ndr->depth--; } +void ndr_print_spoolss_PrinterEnum(struct ndr_print *ndr, const char *name, uint16 level, union spoolss_PrinterEnum *r) +{ + ndr_print_union(ndr, name, level, "spoolss_PrinterEnum"); + switch (level) { + case 1: + ndr_print_spoolss_PrinterEnum1(ndr, "info1", &r->info1); + break; + + case 2: + ndr_print_spoolss_PrinterEnum2(ndr, "info2", &r->info2); + break; + + default: + ndr_print_bad_level(ndr, name, level); + } +} + void ndr_print_spoolss_Devmode(struct ndr_print *ndr, const char *name, struct spoolss_Devmode *r) { ndr_print_struct(ndr, name, "spoolss_Devmode"); diff --git a/source4/librpc/ndr/ndr_spoolss.h b/source4/librpc/ndr/ndr_spoolss.h index 53e504bf17..3c6dffadaf 100644 --- a/source4/librpc/ndr/ndr_spoolss.h +++ b/source4/librpc/ndr/ndr_spoolss.h @@ -68,19 +68,24 @@ struct spoolss_PrinterEnum2 { uint32 averageppm; }; +union spoolss_PrinterEnum { +/* [case(1)] */ struct spoolss_PrinterEnum1 info1; +/* [case(2)] */ struct spoolss_PrinterEnum2 info2; +}; + struct spoolss_EnumPrinters { struct { uint32 flags; const char *server; uint32 level; - uint8 *buf; - uint32 offered; + DATA_BLOB *buffer; + uint32 *buf_size; } in; struct { - union spoolss_PrinterEnum *info; - uint32 *needed; - uint32 returned; + DATA_BLOB *buffer; + uint32 *buf_size; + uint32 count; NTSTATUS result; } out; diff --git a/source4/librpc/ndr/ndr_spoolss_buf.c b/source4/librpc/ndr/ndr_spoolss_buf.c index 2290150b1d..c53a691417 100644 --- a/source4/librpc/ndr/ndr_spoolss_buf.c +++ b/source4/librpc/ndr/ndr_spoolss_buf.c @@ -24,34 +24,19 @@ #include "includes.h" -NTSTATUS ndr_pull_spoolss_PrinterEnum(struct ndr_pull *ndr, int ndr_flags, - uint16 *level, union spoolss_PrinterEnum *info) +NTSTATUS pull_spoolss_PrinterEnumArray(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, + uint16 level, uint32 count, + union spoolss_PrinterEnum **info) { - switch (*level) { - case 1: - NDR_CHECK(ndr_pull_spoolss_PrinterEnum1(ndr, NDR_SCALARS|NDR_BUFFERS, &info->info1)); - break; - case 2: - NDR_CHECK(ndr_pull_spoolss_PrinterEnum2(ndr, NDR_SCALARS|NDR_BUFFERS, &info->info2)); - break; - default: - return NT_STATUS_INVALID_LEVEL; + int i; + struct ndr_pull *ndr; + ndr = ndr_pull_init_blob(blob, mem_ctx); + if (!ndr) { + return NT_STATUS_NO_MEMORY; } - return NT_STATUS_OK; -} - - -void ndr_print_spoolss_PrinterEnum(struct ndr_print *ndr, const char *name, uint16 level, - union spoolss_PrinterEnum *info) -{ - ndr_print_struct(ndr, name, "spoolss_PrinterEnum"); - - switch (level) { - case 1: - ndr_print_spoolss_PrinterEnum1(ndr, "info1", &info->info1); - break; - case 2: - ndr_print_spoolss_PrinterEnum2(ndr, "info2", &info->info2); - break; + NDR_ALLOC_N(ndr, *info, count); + for (i=0;i<count;i++) { + NDR_CHECK(ndr_pull_spoolss_PrinterEnum(ndr, NDR_SCALARS|NDR_BUFFERS, &level, &(*info)[i])); } + return NT_STATUS_OK; } diff --git a/source4/librpc/ndr/ndr_spoolss_buf.h b/source4/librpc/ndr/ndr_spoolss_buf.h index 5670c750a6..3ff43a116c 100644 --- a/source4/librpc/ndr/ndr_spoolss_buf.h +++ b/source4/librpc/ndr/ndr_spoolss_buf.h @@ -21,7 +21,3 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -union spoolss_PrinterEnum { - /* [case(1)] */ struct spoolss_PrinterEnum1 info1; - /* [case(2)] */ struct spoolss_PrinterEnum2 info2; -}; diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index e7e35659d7..d203be2d47 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -30,14 +30,16 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) BOOL ret = True; for (i=0;i<ARRAY_SIZE(levels);i++) { - uint32 needed = 0; - + uint32 buf_size = 0; + union spoolss_PrinterEnum *info; + int j; + r.in.flags = 0x02; r.in.server = ""; r.in.level = levels[i]; - r.in.buf = NULL; - r.in.offered = needed; - r.out.needed = &needed; + r.in.buffer = NULL; + r.in.buf_size = &buf_size; + r.out.buf_size = &buf_size; printf("\nTesting EnumPrinters level %u\n", r.in.level); @@ -48,14 +50,10 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) continue; } - if (NT_STATUS_V(status) == 0x0000007a) { - r.in.buf = talloc(mem_ctx, needed); - if (!r.in.buf) { - ret = False; - continue; - } - memset(r.in.buf, 0xfe, needed); - r.in.offered = needed; + if (NT_STATUS_V(status) == ERRinsufficientbuffer) { + DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, buf_size); + data_blob_clear(&blob); + r.in.buffer = &blob; status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r); } @@ -63,8 +61,14 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) printf("EnumPrinters failed - %s\n", nt_errstr(status)); } - if (r.out.info) { - NDR_PRINT_UNION_DEBUG(spoolss_PrinterEnum, r.in.level, r.out.info); + status = pull_spoolss_PrinterEnumArray(r.out.buffer, mem_ctx, r.in.level, r.out.count, &info); + if (!NT_STATUS_IS_OK(status)) { + printf("EnumPrintersArray parse failed - %s\n", nt_errstr(status)); + } + + for (j=0;j<r.out.count;j++) { + printf("Printer %d\n", j); + NDR_PRINT_UNION_DEBUG(spoolss_PrinterEnum, r.in.level, &info[j]); } } |