From 76e3954dde40506c31ef89e1861f14522efcccf9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 May 2005 01:58:34 +0000 Subject: 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) --- source4/librpc/ndr/ndr.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4') 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 @@ -759,6 +759,27 @@ NTSTATUS ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void * return fn(ndr, NDR_SCALARS|NDR_BUFFERS, p); } +/* + 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 */ -- cgit