summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-11-01 08:10:54 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:43:53 +0100
commit4881d6b7e5d667c518be4cff55d40c46b1086501 (patch)
treed7b955d3920db2eedc256a139d04fb06b87d23c3
parentb5dc54883bbc4f72e20e29f71b844a7403139c5e (diff)
downloadsamba-4881d6b7e5d667c518be4cff55d40c46b1086501.tar.gz
samba-4881d6b7e5d667c518be4cff55d40c46b1086501.tar.bz2
samba-4881d6b7e5d667c518be4cff55d40c46b1086501.zip
r25774: create ndr_pull_union_blob_all() and match the logic of the struct fns
metze (This used to be commit 987deeff55236e2800f8690a5584ff8f7589114e)
-rw-r--r--source4/librpc/ndr/ndr.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c
index d5995f65ce..c209ee8088 100644
--- a/source4/librpc/ndr/ndr.c
+++ b/source4/librpc/ndr/ndr.c
@@ -750,7 +750,7 @@ _PUBLIC_ NTSTATUS ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *me
if (ndr->offset < ndr->data_size) {
return NT_STATUS_PORT_MESSAGE_TOO_LONG;
}
- return status;
+ return NT_STATUS_OK;
}
/*
@@ -760,6 +760,22 @@ _PUBLIC_ NTSTATUS ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx
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);
@@ -769,10 +785,10 @@ _PUBLIC_ NTSTATUS ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx
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;
}
/*