s4:librpc/rpc: make dcerpc_pipe->binding const
authorStefan Metzmacher <metze@samba.org>
Wed, 12 Feb 2014 11:24:29 +0000 (12:24 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 13 Feb 2014 10:54:18 +0000 (11:54 +0100)
This should not be changed after the connection is
ready for requests.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source4/librpc/rpc/dcerpc.c
source4/librpc/rpc/dcerpc.h
source4/librpc/rpc/dcerpc_smb.c

index 919be770cdb5983e8604967fffe31aa6a6a46506..31dca6a396d435115f847e7f29aa148a5c1845ef 100644 (file)
@@ -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;
        }
index d1b5ffbfcb1547f8935f4e3ff293f87a19f91d8e..6d9413aa47f834c22c2c8ca4045ab020c46a6243 100644 (file)
@@ -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;
index 0224fdfb194596cbb885002943d99f0a196317d2..9b40ecac30a21392715603d4e90cbbe0e4c56be7 100644 (file)
@@ -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,