s4-rpc_server: Avoid extern reference to dcesrv_mgmt_interface and memcpy()
authorAndrew Bartlett <abartlet@samba.org>
Sun, 20 Nov 2016 22:31:27 +0000 (11:31 +1300)
committerStefan Metzmacher <metze@samba.org>
Thu, 8 Dec 2016 08:28:26 +0000 (09:28 +0100)
Use a typesafe struct-returning function instead

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/rpc_server/dcerpc_server.c
source4/rpc_server/dcesrv_mgmt.c

index 862127b578510f8a7a21bef6c1b0b5d48b499238..072e35249c0b065cc321d7dbf05949eaeba8f5ee 100644 (file)
@@ -42,8 +42,6 @@
 #include "lib/util/samba_modules.h"
 #include "librpc/gen_ndr/ndr_dcerpc.h"
 
-extern const struct dcesrv_interface dcesrv_mgmt_interface;
-
 static NTSTATUS dcesrv_negotiate_contexts(struct dcesrv_call_state *call,
                                const struct dcerpc_bind *b,
                                struct dcerpc_ack_ctx *ack_ctx_list);
@@ -283,8 +281,7 @@ _PUBLIC_ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
                        return NT_STATUS_NO_MEMORY;
                }
 
-               memcpy(&(ifl->iface), &dcesrv_mgmt_interface, 
-                          sizeof(struct dcesrv_interface));
+               ifl->iface = dcesrv_get_mgmt_interface();
 
                DLIST_ADD(ep->interface_list, ifl);
        }
index 4d3428d13cff7ecc13b0c29478b0bee04b3af58d..577f0fbb3696dc226f85f1d9f3873227af011a6e 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "includes.h"
 #include "rpc_server/dcerpc_server.h"
+#include "rpc_server/dcerpc_server_proto.h"
 #include "librpc/gen_ndr/ndr_mgmt.h"
 
 #define DCESRV_INTERFACE_MGMT_BIND(call, iface) \
@@ -107,3 +108,8 @@ static WERROR dcesrv_mgmt_inq_princ_name(struct dcesrv_call_state *dce_call, TAL
 
 /* include the generated boilerplate */
 #include "librpc/gen_ndr/ndr_mgmt_s.c"
+
+const struct dcesrv_interface dcesrv_get_mgmt_interface(void)
+{
+       return dcesrv_mgmt_interface;
+}