diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-05-10 01:58:34 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:16:34 -0500 |
commit | 76e3954dde40506c31ef89e1861f14522efcccf9 (patch) | |
tree | b371f00f5e3f76e9744ec63caaf7e5d349528a9a /source4/librpc/ndr | |
parent | f6c0bee79125e779ab0036a77506e2f688c4872f (diff) | |
download | samba-76e3954dde40506c31ef89e1861f14522efcccf9.tar.gz samba-76e3954dde40506c31ef89e1861f14522efcccf9.tar.bz2 samba-76e3954dde40506c31ef89e1861f14522efcccf9.zip |
r6690: added ndr_pull_struct_blob_all(), which is like ndr_pull_struct_blob() but checks
that all bytes are consumed
(This used to be commit 7951e9bd647b35d2f92d7ba4dbbc2ac05f31491a)
Diffstat (limited to 'source4/librpc/ndr')
-rw-r--r-- | source4/librpc/ndr/ndr.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index e21ec72ec8..79af5967c7 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -760,6 +760,27 @@ NTSTATUS ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void * } /* + pull a struct from a blob using NDR - failing if all bytes are not consumed +*/ +NTSTATUS ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, + ndr_pull_flags_fn_t fn) +{ + struct ndr_pull *ndr; + NTSTATUS status; + + ndr = ndr_pull_init_blob(blob, mem_ctx); + if (!ndr) { + return NT_STATUS_NO_MEMORY; + } + status = fn(ndr, NDR_SCALARS|NDR_BUFFERS, p); + if (!NT_STATUS_IS_OK(status)) return status; + if (ndr->offset != ndr->data_size) { + return NT_STATUS_BUFFER_TOO_SMALL; + } + return status; +} + +/* push a struct to a blob using NDR */ NTSTATUS ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, |