From: Stefan Metzmacher Date: Fri, 24 Jan 2014 08:24:49 +0000 (+0100) Subject: librpc/rpc: let derpc_binding_string() add ncacn_options before key=value options X-Git-Tag: tdb-1.2.13~450 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=c327a60a027ba06dbc67921055bb88f9a573096d;p=samba.git librpc/rpc: let derpc_binding_string() add ncacn_options before key=value options Signed-off-by: Stefan Metzmacher Reviewed-by: Guenther Deschner --- diff --git a/librpc/rpc/binding.c b/librpc/rpc/binding.c index d55939031f6..975ee554f87 100644 --- a/librpc/rpc/binding.c +++ b/librpc/rpc/binding.c @@ -238,28 +238,27 @@ _PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_bi } } - /* this is a *really* inefficent way of dealing with strings, - but this is rarely called and the strings are always short, - so I don't care */ - for (i=0;b->options && b->options[i];i++) { + for (i=0;iflags & ncacn_options[i].flag)) { + continue; + } + o = s; - s = talloc_asprintf_append_buffer(s, ",%s", b->options[i]); + if (ncacn_options[i].flag == DCERPC_LOCALADDRESS && b->localaddress) { + s = talloc_asprintf_append_buffer(s, ",%s=%s", ncacn_options[i].name, + b->localaddress); + } else { + s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name); + } if (s == NULL) { talloc_free(o); return NULL; } } - for (i=0;ioptions && b->options[i];i++) { o = s; - if (b->flags & ncacn_options[i].flag) { - if (ncacn_options[i].flag == DCERPC_LOCALADDRESS && b->localaddress) { - s = talloc_asprintf_append_buffer(s, ",%s=%s", ncacn_options[i].name, - b->localaddress); - } else { - s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name); - } - } + s = talloc_asprintf_append_buffer(s, ",%s", b->options[i]); if (s == NULL) { talloc_free(o); return NULL; diff --git a/source4/librpc/tests/binding_string.c b/source4/librpc/tests/binding_string.c index fcefd69488d..d3150e21762 100644 --- a/source4/librpc/tests/binding_string.c +++ b/source4/librpc/tests/binding_string.c @@ -82,7 +82,7 @@ static const char *test_strings[] = { "ncacn_ip_tcp:127.0.0.1", "ncacn_ip_tcp:127.0.0.1[20]", "ncacn_ip_tcp:127.0.0.1[20,sign]", - "ncacn_ip_tcp:127.0.0.1[20,Security=Foobar,sign]", + "ncacn_ip_tcp:127.0.0.1[20,sign,Security=Foobar]", "ncacn_http:127.0.0.1", "ncacn_http:127.0.0.1[78]", "ncacn_http:127.0.0.1[78,ProxyServer=myproxy:3128]",