r6690: added ndr_pull_struct_blob_all(), which is like ndr_pull_struct_blob() but...
authorAndrew Tridgell <tridge@samba.org>
Tue, 10 May 2005 01:58:34 +0000 (01:58 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:16:34 +0000 (13:16 -0500)
that all bytes are consumed

source/librpc/ndr/ndr.c

index e21ec72ec80fa700e44585946fecbe8201020c19..79af5967c754e7ac56186b6e04dfbc82e6f18234 100644 (file)
@@ -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
 */