diff options
author | Stefan Metzmacher <metze@samba.org> | 2014-01-24 16:56:34 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2014-02-13 11:54:15 +0100 |
commit | f066bd7b33e6c44311af7d82835017aac0b85c0d (patch) | |
tree | 3d04dadaa59556535ac803d587c0b899578bf664 /librpc/rpc/binding.c | |
parent | 8dac96728aee72f4d5510d53c3b00bdbd250a867 (diff) | |
download | samba-f066bd7b33e6c44311af7d82835017aac0b85c0d.tar.gz |
librpc/rpc: add dcerpc_binding_[g|s]et_object()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Diffstat (limited to 'librpc/rpc/binding.c')
-rw-r--r-- | librpc/rpc/binding.c | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/librpc/rpc/binding.c b/librpc/rpc/binding.c index 09c0c8d6cbc..43bbbce2540 100644 --- a/librpc/rpc/binding.c +++ b/librpc/rpc/binding.c @@ -428,6 +428,35 @@ _PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *_s, stru return NT_STATUS_OK; } +_PUBLIC_ struct GUID dcerpc_binding_get_object(const struct dcerpc_binding *b) +{ + return b->object.uuid; +} + +_PUBLIC_ NTSTATUS dcerpc_binding_set_object(struct dcerpc_binding *b, + struct GUID object) +{ + char *tmp = discard_const_p(char, b->object_string); + + if (GUID_all_zero(&object)) { + talloc_free(tmp); + b->object_string = NULL; + ZERO_STRUCT(b->object); + return NT_STATUS_OK; + } + + b->object_string = GUID_string(b, &object); + if (b->object_string == NULL) { + b->object_string = tmp; + return NT_STATUS_NO_MEMORY; + } + talloc_free(tmp); + + ZERO_STRUCT(b->object); + b->object.uuid = object; + return NT_STATUS_OK; +} + _PUBLIC_ void dcerpc_binding_get_auth_info(const struct dcerpc_binding *b, enum dcerpc_AuthType *_auth_type, enum dcerpc_AuthLevel *_auth_level) @@ -598,39 +627,23 @@ _PUBLIC_ NTSTATUS dcerpc_binding_set_string_option(struct dcerpc_binding *b, ret = strcmp(name, "object"); if (ret == 0) { - DATA_BLOB blob; NTSTATUS status; - struct GUID uuid; - - tmp = discard_const_p(char, b->object_string); + struct GUID uuid = GUID_zero(); - if (value == NULL) { - talloc_free(tmp); - b->object_string = NULL; - ZERO_STRUCT(b->object); - return NT_STATUS_OK; - } - - blob = data_blob_string_const(value); - if (blob.length != 36) { - return NT_STATUS_INVALID_PARAMETER_MIX; - } - - status = GUID_from_data_blob(&blob, &uuid); - if (!NT_STATUS_IS_OK(status)) { - return status; - } + if (value != NULL) { + DATA_BLOB blob; + blob = data_blob_string_const(value); + if (blob.length != 36) { + return NT_STATUS_INVALID_PARAMETER_MIX; + } - b->object_string = GUID_string(b, &uuid); - if (b->object_string == NULL) { - b->object_string = tmp; - return NT_STATUS_NO_MEMORY; + status = GUID_from_data_blob(&blob, &uuid); + if (!NT_STATUS_IS_OK(status)) { + return status; + } } - talloc_free(tmp); - ZERO_STRUCT(b->object); - b->object.uuid = uuid; - return NT_STATUS_OK; + return dcerpc_binding_set_object(b, uuid); } for (i=0; i < ARRAY_SIZE(specials); i++) { |