diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-12-10 11:22:20 +1100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2011-01-13 17:58:50 +0100 |
commit | 2a1568f81ba488f6e7d3a90ac6fbab30578e2041 (patch) | |
tree | e3629e9f9901f81a06e9d4db8033b001649f0d0d /librpc | |
parent | d3a6a079c0bde67ccc1cbe4d20210f2077fc4f19 (diff) | |
download | samba-2a1568f81ba488f6e7d3a90ac6fbab30578e2041.tar.gz |
librpc: split out a separate GUID_from_ndr_blob() function
This will simplify many of the places that deal with NDR formatted
GUIDs
(cherry picked from commit effff544265c63c95cf630d426b630bfe4d25aec)
This patch is part of a fix for bug #7538 (Backport fixes for
GUID_from_data_blob).
(cherry picked from commit e8ed2b596627e8704e3384d5997020059b47144a)
(cherry picked from commit 82d609cefbb6177738fd78ca017d4196b80a0718)
Diffstat (limited to 'librpc')
-rw-r--r-- | librpc/ndr/libndr.h | 1 | ||||
-rw-r--r-- | librpc/ndr/uuid.c | 35 |
2 files changed, 21 insertions, 15 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index f730ed8f322..e1bcdb9b477 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -522,6 +522,7 @@ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const ch /* GUIDs */ bool GUID_equal(const struct GUID *u1, const struct GUID *u2); +NTSTATUS GUID_from_ndr_blob(const DATA_BLOB *b, struct GUID *guid); NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid); NTSTATUS GUID_from_string(const char *s, struct GUID *guid); NTSTATUS NS_GUID_from_string(const char *s, struct GUID *guid); diff --git a/librpc/ndr/uuid.c b/librpc/ndr/uuid.c index 80c35cde861..928971298c3 100644 --- a/librpc/ndr/uuid.c +++ b/librpc/ndr/uuid.c @@ -25,6 +25,25 @@ #include "librpc/ndr/libndr.h" #include "librpc/gen_ndr/ndr_misc.h" + +/** + build a GUID from a NDR data blob +*/ +_PUBLIC_ NTSTATUS GUID_from_ndr_blob(const DATA_BLOB *b, struct GUID *guid) +{ + enum ndr_err_code ndr_err; + TALLOC_CTX *mem_ctx; + + mem_ctx = talloc_new(NULL); + NT_STATUS_HAVE_NO_MEMORY(mem_ctx); + + ndr_err = ndr_pull_struct_blob_all(b, mem_ctx, NULL, guid, + (ndr_pull_flags_fn_t)ndr_pull_GUID); + talloc_free(mem_ctx); + return ndr_map_error2ntstatus(ndr_err); +} + + /** build a GUID from a string */ @@ -90,21 +109,7 @@ _PUBLIC_ NTSTATUS GUID_from_data_blob(const DATA_BLOB *s, struct GUID *guid) } 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; + return GUID_from_ndr_blob(s, guid); } if (!NT_STATUS_IS_OK(status)) { |