From 4d4e4ef619682801746def5b6ebd4deea8bd7368 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 12 Feb 2014 12:24:29 +0100 Subject: [PATCH 1/1] s4:librpc/rpc: make dcerpc_pipe->binding const This should not be changed after the connection is ready for requests. Signed-off-by: Stefan Metzmacher Reviewed-by: Guenther Deschner --- source4/librpc/rpc/dcerpc.c | 10 +++++++--- source4/librpc/rpc/dcerpc.h | 2 +- source4/librpc/rpc/dcerpc_smb.c | 10 ++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index 919be770cdb..31dca6a396d 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -1294,6 +1294,7 @@ static void dcerpc_bind_recv_handler(struct rpc_request *subreq, tevent_req_data(req, struct dcerpc_bind_state); struct dcecli_connection *conn = state->p->conn; + struct dcerpc_binding *b = NULL; NTSTATUS status; uint32_t flags; @@ -1376,9 +1377,12 @@ static void dcerpc_bind_recv_handler(struct rpc_request *subreq, } } - - status = dcerpc_binding_set_assoc_group_id(state->p->binding, - pkt->u.bind_ack.assoc_group_id); + /* + * We're the owner of the binding, so we're allowed to modify it. + */ + b = discard_const_p(struct dcerpc_binding, state->p->binding); + status = dcerpc_binding_set_assoc_group_id(b, + pkt->u.bind_ack.assoc_group_id); if (tevent_req_nterror(req, status)) { return; } diff --git a/source4/librpc/rpc/dcerpc.h b/source4/librpc/rpc/dcerpc.h index d1b5ffbfcb1..6d9413aa47f 100644 --- a/source4/librpc/rpc/dcerpc.h +++ b/source4/librpc/rpc/dcerpc.h @@ -112,7 +112,7 @@ struct dcerpc_pipe { struct ndr_syntax_id transfer_syntax; struct dcecli_connection *conn; - struct dcerpc_binding *binding; + const struct dcerpc_binding *binding; /** the last fault code from a DCERPC fault */ uint32_t last_fault_code; diff --git a/source4/librpc/rpc/dcerpc_smb.c b/source4/librpc/rpc/dcerpc_smb.c index 0224fdfb194..9b40ecac30a 100644 --- a/source4/librpc/rpc/dcerpc_smb.c +++ b/source4/librpc/rpc/dcerpc_smb.c @@ -203,6 +203,7 @@ _PUBLIC_ NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe *p, /* if we don't have a binding on this pipe yet, then create one */ if (p->binding == NULL) { + struct dcerpc_binding *b; NTSTATUS status; const char *r = smbXcli_conn_remote_name(conn); char *str; @@ -211,12 +212,12 @@ _PUBLIC_ NTSTATUS dcerpc_pipe_open_smb(struct dcerpc_pipe *p, if (str == NULL) { return NT_STATUS_NO_MEMORY; } - status = dcerpc_parse_binding(p, str, - &p->binding); + status = dcerpc_parse_binding(p, str, &b); talloc_free(str); if (!NT_STATUS_IS_OK(status)) { return status; } + p->binding = b; } ctx = dcerpc_pipe_open_smb_send(p->conn, @@ -247,6 +248,7 @@ _PUBLIC_ NTSTATUS dcerpc_pipe_open_smb2(struct dcerpc_pipe *p, /* if we don't have a binding on this pipe yet, then create one */ if (p->binding == NULL) { + struct dcerpc_binding *b; NTSTATUS status; const char *r = smbXcli_conn_remote_name(conn); char *str; @@ -255,12 +257,12 @@ _PUBLIC_ NTSTATUS dcerpc_pipe_open_smb2(struct dcerpc_pipe *p, if (str == NULL) { return NT_STATUS_NO_MEMORY; } - status = dcerpc_parse_binding(p, str, - &p->binding); + status = dcerpc_parse_binding(p, str, &b); talloc_free(str); if (!NT_STATUS_IS_OK(status)) { return status; } + p->binding = b; } ctx = dcerpc_pipe_open_smb_send(p->conn, -- 2.34.1