diff options
author | metze <metze@0c0555d6-39d7-0310-84fc-f1cc0bd64818> | 2007-11-01 08:10:54 +0000 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2007-11-07 12:10:29 +0100 |
commit | fbb8cff0b801f61dfe93688223cd82a639e0b7cc (patch) | |
tree | af977a093fae0f6b4678cb0920731d57d6667c67 /source3 | |
parent | 1ee8607d4a2d796e15e4668f18f70b60b43ec6e5 (diff) | |
download | samba-fbb8cff0b801f61dfe93688223cd82a639e0b7cc.tar.gz samba-fbb8cff0b801f61dfe93688223cd82a639e0b7cc.tar.bz2 samba-fbb8cff0b801f61dfe93688223cd82a639e0b7cc.zip |
create ndr_pull_union_blob_all() and match the logic of the struct fns
metze
git-svn-id: svn+ssh://svn.samba.org/data/svn/samba/branches/SAMBA_4_0@25774 0c0555d6-39d7-0310-84fc-f1cc0bd64818
(This used to be commit 8ed241532a069c4207945d5f1ceb1ec817ba7976)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/librpc/ndr/ndr.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/source3/librpc/ndr/ndr.c b/source3/librpc/ndr/ndr.c index 326ab12e9b..3ceb728a3f 100644 --- a/source3/librpc/ndr/ndr.c +++ b/source3/librpc/ndr/ndr.c @@ -713,7 +713,7 @@ NTSTATUS ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, vo if (ndr->offset < ndr->data_size) { return NT_STATUS_PORT_MESSAGE_TOO_LONG; } - return status; + return NT_STATUS_OK; } /* @@ -723,6 +723,22 @@ NTSTATUS ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p uint32_t level, ndr_pull_flags_fn_t fn) { struct ndr_pull *ndr; + ndr = ndr_pull_init_blob(blob, mem_ctx); + if (!ndr) { + return NT_STATUS_NO_MEMORY; + } + ndr_pull_set_switch_value(ndr, p, level); + return fn(ndr, NDR_SCALARS|NDR_BUFFERS, p); +} + +/* + pull a union from a blob using NDR, given the union discriminator, + failing if all bytes are not consumed +*/ +_PUBLIC_ NTSTATUS ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, + uint32_t level, ndr_pull_flags_fn_t fn) +{ + struct ndr_pull *ndr; NTSTATUS status; ndr = ndr_pull_init_blob(blob, mem_ctx); @@ -732,10 +748,10 @@ NTSTATUS ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p ndr_pull_set_switch_value(ndr, p, level); 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; + if (ndr->offset < ndr->data_size) { + return NT_STATUS_PORT_MESSAGE_TOO_LONG; } - return status; + return NT_STATUS_OK; } /* |