summaryrefslogtreecommitdiff
path: root/source4/librpc/rpc
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-08-08 13:56:51 +0200
committerAndrew Bartlett <abartlet@samba.org>2013-08-12 16:48:46 +1200
commitae6166a3c10d3ce9f9a0d08dcbfcc8afd72ca461 (patch)
tree3eadbf0b231becd27d20d0c3925d7e8445b8cea7 /source4/librpc/rpc
parentb055b3118d9c2159e9d5a42830328cfc103f9555 (diff)
downloadsamba-ae6166a3c10d3ce9f9a0d08dcbfcc8afd72ca461.tar.gz
samba-ae6166a3c10d3ce9f9a0d08dcbfcc8afd72ca461.tar.bz2
samba-ae6166a3c10d3ce9f9a0d08dcbfcc8afd72ca461.zip
s4:librpc: avoid talloc_reference() in dcerpc_epm_map_binding_send()
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/librpc/rpc')
-rw-r--r--source4/librpc/rpc/dcerpc_connect.c15
-rw-r--r--source4/librpc/rpc/dcerpc_sock.c14
-rw-r--r--source4/librpc/rpc/dcerpc_util.c18
3 files changed, 35 insertions, 12 deletions
diff --git a/source4/librpc/rpc/dcerpc_connect.c b/source4/librpc/rpc/dcerpc_connect.c
index 280b7aeb0e..eb53a115e3 100644
--- a/source4/librpc/rpc/dcerpc_connect.c
+++ b/source4/librpc/rpc/dcerpc_connect.c
@@ -323,9 +323,18 @@ static struct composite_context* dcerpc_pipe_connect_ncacn_ip_tcp_send(TALLOC_CT
/* store input parameters in state structure */
s->io = *io;
- s->localaddr = talloc_reference(c, io->binding->localaddress);
- s->host = talloc_reference(c, io->binding->host);
- s->target_hostname = talloc_reference(c, io->binding->target_hostname);
+ if (io->binding->localaddress != NULL) {
+ s->localaddr = talloc_strdup(s, io->binding->localaddress);
+ if (composite_nomem(s->localaddr, c)) return c;
+ }
+ if (io->binding->host != NULL) {
+ s->host = talloc_strdup(s, io->binding->host);
+ if (composite_nomem(s->host, c)) return c;
+ }
+ if (io->binding->target_hostname != NULL) {
+ s->target_hostname = talloc_strdup(s, io->binding->target_hostname);
+ if (composite_nomem(s->target_hostname, c)) return c;
+ }
/* port number is a binding endpoint here */
s->port = atoi(io->binding->endpoint);
diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c
index 58fca4ce37..a911dba825 100644
--- a/source4/librpc/rpc/dcerpc_sock.c
+++ b/source4/librpc/rpc/dcerpc_sock.c
@@ -327,12 +327,15 @@ static struct composite_context *dcerpc_pipe_open_socket_send(TALLOC_CTX *mem_ct
s->conn = cn;
s->transport = transport;
if (localaddr) {
- s->localaddr = talloc_reference(c, localaddr);
+ s->localaddr = socket_address_copy(s, localaddr);
if (composite_nomem(s->localaddr, c)) return c;
}
- s->server = talloc_reference(c, server);
+ s->server = socket_address_copy(s, server);
if (composite_nomem(s->server, c)) return c;
- s->target_hostname = talloc_reference(s, target_hostname);
+ if (target_hostname) {
+ s->target_hostname = talloc_strdup(s, target_hostname);
+ if (composite_nomem(s->target_hostname, c)) return c;
+ }
s->sock = talloc(cn, struct sock_private);
if (composite_nomem(s->sock, c)) return c;
@@ -342,7 +345,10 @@ static struct composite_context *dcerpc_pipe_open_socket_send(TALLOC_CTX *mem_ct
talloc_steal(s->sock, s->socket_ctx);
- s->sock->path = talloc_reference(s->sock, full_path);
+ if (full_path != NULL) {
+ s->sock->path = talloc_strdup(s->sock, full_path);
+ if (composite_nomem(s->sock->path, c)) return c;
+ }
conn_req = socket_connect_send(s->socket_ctx, s->localaddr, s->server, 0,
c->event_ctx);
diff --git a/source4/librpc/rpc/dcerpc_util.c b/source4/librpc/rpc/dcerpc_util.c
index 2a0c40566d..1364fdce35 100644
--- a/source4/librpc/rpc/dcerpc_util.c
+++ b/source4/librpc/rpc/dcerpc_util.c
@@ -203,8 +203,8 @@ static void continue_epm_map(struct tevent_req *subreq)
}
/* get received endpoint */
- s->binding->endpoint = talloc_reference(s->binding,
- dcerpc_floor_get_rhs_data(c, &s->twr_r->tower.floors[3]));
+ s->binding->endpoint = dcerpc_floor_get_rhs_data(s->binding,
+ &s->twr_r->tower.floors[3]);
if (composite_nomem(s->binding->endpoint, c)) return;
composite_done(c);
@@ -249,6 +249,7 @@ struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx,
/* anonymous credentials for rpc connection used to get endpoint mapping */
anon_creds = cli_credentials_init(mem_ctx);
+ if (composite_nomem(anon_creds, c)) return c;
cli_credentials_set_anonymous(anon_creds);
/*
@@ -266,7 +267,8 @@ struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx,
binding->transport = default_binding->transport;
if (default_binding->transport == binding->transport &&
default_binding->endpoint) {
- binding->endpoint = talloc_reference(binding, default_binding->endpoint);
+ binding->endpoint = talloc_strdup(binding, default_binding->endpoint);
+ if (composite_nomem(binding->endpoint, c)) return c;
talloc_free(default_binding);
composite_done(c);
@@ -284,10 +286,16 @@ struct composite_context *dcerpc_epm_map_binding_send(TALLOC_CTX *mem_ctx,
/* basic endpoint mapping data */
epmapper_binding->transport = binding->transport;
- epmapper_binding->host = talloc_reference(epmapper_binding, binding->host);
+ if (binding->host != NULL) {
+ epmapper_binding->host = talloc_strdup(epmapper_binding, binding->host);
+ if (composite_nomem(epmapper_binding->host, c)) return c;
+ }
epmapper_binding->target_hostname = epmapper_binding->host;
epmapper_binding->options = NULL;
- epmapper_binding->localaddress = talloc_reference(epmapper_binding, binding->localaddress);
+ if (binding->localaddress != NULL) {
+ epmapper_binding->localaddress = talloc_strdup(epmapper_binding, binding->localaddress);
+ if (composite_nomem(epmapper_binding->localaddress, c)) return c;
+ }
epmapper_binding->flags = 0;
epmapper_binding->assoc_group_id = 0;
epmapper_binding->endpoint = NULL;