summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2008-11-13 21:27:10 +0100
committerStefan Metzmacher <metze@samba.org>2008-11-16 16:24:34 +0100
commit69af236e7772e85b7b8dc7045c6737d85f4b189a (patch)
tree9e5b6b537a4ef464d87f29cc773c5f113d09d89c
parent1290b1d3d3ed2c81862fd7ad716e3776e5793632 (diff)
downloadsamba-69af236e7772e85b7b8dc7045c6737d85f4b189a.tar.gz
samba-69af236e7772e85b7b8dc7045c6737d85f4b189a.tar.bz2
samba-69af236e7772e85b7b8dc7045c6737d85f4b189a.zip
librpc/ndr: let GUID_from_data_blob() accept a ndr blob or a hex string too
metze
-rw-r--r--librpc/ndr/uuid.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/librpc/ndr/uuid.c b/librpc/ndr/uuid.c
index 308b5c0688..bb8c49254d 100644
--- a/librpc/ndr/uuid.c
+++ b/librpc/ndr/uuid.c
@@ -23,6 +23,7 @@
#include "includes.h"
#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/ndr_misc.h"
/**
build a GUID from a string
@@ -34,6 +35,8 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid)
uint32_t time_mid, time_hi_and_version;
uint32_t clock_seq[2];
uint32_t node[6];
+ uint8_t buf16[16];
+ DATA_BLOB blob16 = data_blob_const(buf16, sizeof(buf16));
int i;
if (s->data == NULL) {
@@ -54,6 +57,32 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid)
&clock_seq[0], &clock_seq[1],
&node[0], &node[1], &node[2], &node[3], &node[4], &node[5])) {
status = NT_STATUS_OK;
+ } else if (s->length == 32) {
+ size_t rlen = strhex_to_str((char *)blob16.data, blob16.length,
+ (const char *)s->data, s->length);
+ if (rlen == blob16.length) {
+ /* goto the ndr_pull_struct_blob() path */
+ status = NT_STATUS_OK;
+ s = &blob16;
+ }
+ }
+
+ if (s->length == 16) {
+ enum ndr_err_code ndr_err;
+ struct GUID guid2;
+ TALLOC_CTX *mem_ctx;
+
+ mem_ctx = talloc_new(NULL);
+ NT_STATUS_HAVE_NO_MEMORY(mem_ctx);
+
+ ndr_err = ndr_pull_struct_blob(s, mem_ctx, NULL, &guid2,
+ (ndr_pull_flags_fn_t)ndr_pull_GUID);
+ talloc_free(mem_ctx);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+ *guid = guid2;
+ return NT_STATUS_OK;
}
if (!NT_STATUS_IS_OK(status)) {