summaryrefslogtreecommitdiffstats
path: root/librpc
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-02-07 14:50:11 +0100
committerGünther Deschner <gd@samba.org>2014-02-13 11:54:15 +0100
commitf2c058bf2a46915d73daedd87ef5273e880abf50 (patch)
tree8377c9b091e7795dce6d4d86365a662c24141dfd /librpc
parentebc18694a13b0860c222644372d76a2621d87384 (diff)
downloadsamba-f2c058bf2a46915d73daedd87ef5273e880abf50.tar.gz
samba-f2c058bf2a46915d73daedd87ef5273e880abf50.tar.xz
samba-f2c058bf2a46915d73daedd87ef5273e880abf50.zip
librpc/rpc: avoid loosing data with dcerpc_binding_string() -> dcerpc_parse_binding()
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org>
Diffstat (limited to 'librpc')
-rw-r--r--librpc/rpc/binding.c55
1 files changed, 54 insertions, 1 deletions
diff --git a/librpc/rpc/binding.c b/librpc/rpc/binding.c
index 2b584b57326..6a9a5ea41c3 100644
--- a/librpc/rpc/binding.c
+++ b/librpc/rpc/binding.c
@@ -198,6 +198,8 @@ _PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_bi
char *o = s;
int i;
const char *t_name = NULL;
+ bool option_section = false;
+ const char *target_hostname = NULL;
if (b->transport != NCA_UNKNOWN) {
t_name = derpc_transport_string_by_transport(b->transport);
@@ -235,7 +237,28 @@ _PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_bi
}
}
- if (!b->endpoint && !b->options && !b->flags) {
+ target_hostname = b->target_hostname;
+ if (target_hostname != NULL && b->host != NULL) {
+ if (strcmp(target_hostname, b->host) == 0) {
+ target_hostname = NULL;
+ }
+ }
+
+ if (b->endpoint) {
+ option_section = true;
+ } else if (target_hostname) {
+ option_section = true;
+ } else if (b->target_principal) {
+ option_section = true;
+ } else if (b->assoc_group_id != 0) {
+ option_section = true;
+ } else if (b->options) {
+ option_section = true;
+ } else if (b->flags) {
+ option_section = true;
+ }
+
+ if (!option_section) {
return s;
}
@@ -268,6 +291,36 @@ _PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_bi
}
}
+ if (target_hostname) {
+ o = s;
+ s = talloc_asprintf_append_buffer(s, ",target_hostname=%s",
+ b->target_hostname);
+ if (s == NULL) {
+ talloc_free(o);
+ return NULL;
+ }
+ }
+
+ if (b->target_principal) {
+ o = s;
+ s = talloc_asprintf_append_buffer(s, ",target_principal=%s",
+ b->target_principal);
+ if (s == NULL) {
+ talloc_free(o);
+ return NULL;
+ }
+ }
+
+ if (b->assoc_group_id != 0) {
+ o = s;
+ s = talloc_asprintf_append_buffer(s, ",assoc_group_id=0x%08x",
+ b->assoc_group_id);
+ if (s == NULL) {
+ talloc_free(o);
+ return NULL;
+ }
+ }
+
for (i=0;b->options && b->options[i];i++) {
o = s;
s = talloc_asprintf_append_buffer(s, ",%s", b->options[i]);