svn commit: samba r25774 - in branches/SAMBA_4_0/source/librpc/ndr:
.
metze at samba.org
metze at samba.org
Thu Nov 1 08:10:54 GMT 2007
Author: metze
Date: 2007-11-01 08:10:54 +0000 (Thu, 01 Nov 2007)
New Revision: 25774
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25774
Log:
create ndr_pull_union_blob_all() and match the logic of the struct fns
metze
Modified:
branches/SAMBA_4_0/source/librpc/ndr/ndr.c
Changeset:
Modified: branches/SAMBA_4_0/source/librpc/ndr/ndr.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/ndr/ndr.c 2007-11-01 08:00:36 UTC (rev 25773)
+++ branches/SAMBA_4_0/source/librpc/ndr/ndr.c 2007-11-01 08:10:54 UTC (rev 25774)
@@ -750,7 +750,7 @@
if (ndr->offset < ndr->data_size) {
return NT_STATUS_PORT_MESSAGE_TOO_LONG;
}
- return status;
+ return NT_STATUS_OK;
}
/*
@@ -760,6 +760,22 @@
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 @@
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;
}
/*
More information about the samba-cvs
mailing list