summaryrefslogtreecommitdiff
path: root/librpc
diff options
context:
space:
mode:
authorSamuel Cabrero <scabrero@samba.org>2019-10-01 16:48:01 +0200
committerAndreas Schneider <asn@cryptomilk.org>2019-10-18 16:07:37 +0000
commit6a6546b565793341f3be6a6fcf30a40a186f9ae9 (patch)
tree2d065ccfedb8ee13d663d0216c3afc2d6da5449f /librpc
parent52727543b05c80742e187014ce1048fe7b104bdc (diff)
downloadsamba-6a6546b565793341f3be6a6fcf30a40a186f9ae9.tar.gz
librpc:core: Allocate struct dcesrv_interface with talloc
The S3 implementation needs to reinit the dcesrv_context and free the endpoints list with their registered interfaces. Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'librpc')
-rw-r--r--librpc/rpc/dcesrv_core.c24
-rw-r--r--librpc/rpc/dcesrv_core.h2
-rw-r--r--librpc/rpc/dcesrv_mgmt.c6
3 files changed, 22 insertions, 10 deletions
diff --git a/librpc/rpc/dcesrv_core.c b/librpc/rpc/dcesrv_core.c
index f7f0e627e33..132649665df 100644
--- a/librpc/rpc/dcesrv_core.c
+++ b/librpc/rpc/dcesrv_core.c
@@ -122,8 +122,8 @@ static const struct dcesrv_interface *find_interface_by_binding(struct dcesrv_co
if (endpoints_match(ep->ep_description, binding)) {
struct dcesrv_if_list *ifl;
for (ifl=ep->interface_list; ifl; ifl=ifl->next) {
- if (interface_match(&(ifl->iface), iface)) {
- return &(ifl->iface);
+ if (interface_match(ifl->iface, iface)) {
+ return ifl->iface;
}
}
}
@@ -149,8 +149,8 @@ const struct dcesrv_interface *find_interface_by_uuid(const struct dcesrv_endpoi
{
struct dcesrv_if_list *ifl;
for (ifl=endpoint->interface_list; ifl; ifl=ifl->next) {
- if (interface_match_by_uuid(&(ifl->iface), uuid, if_version)) {
- return &(ifl->iface);
+ if (interface_match_by_uuid(ifl->iface, uuid, if_version)) {
+ return ifl->iface;
}
}
return NULL;
@@ -322,7 +322,13 @@ _PUBLIC_ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
return NT_STATUS_NO_MEMORY;
}
- ifl->iface = dcesrv_get_mgmt_interface();
+ ifl->iface = talloc_memdup(ifl,
+ dcesrv_get_mgmt_interface(),
+ sizeof(struct dcesrv_interface));
+ if (ifl->iface == NULL) {
+ talloc_free(ep);
+ return NT_STATUS_NO_MEMORY;
+ }
DLIST_ADD(ep->interface_list, ifl);
}
@@ -346,7 +352,13 @@ _PUBLIC_ NTSTATUS dcesrv_interface_register(struct dcesrv_context *dce_ctx,
}
/* copy the given interface struct to the one on the endpoints interface list */
- memcpy(&(ifl->iface),iface, sizeof(struct dcesrv_interface));
+ ifl->iface = talloc_memdup(ifl,
+ iface,
+ sizeof(struct dcesrv_interface));
+ if (ifl->iface == NULL) {
+ talloc_free(ep);
+ return NT_STATUS_NO_MEMORY;
+ }
/* if we have a security descriptor given,
* we should see if we can set it up on the endpoint
diff --git a/librpc/rpc/dcesrv_core.h b/librpc/rpc/dcesrv_core.h
index 8e2f1a750a3..663a09b418a 100644
--- a/librpc/rpc/dcesrv_core.h
+++ b/librpc/rpc/dcesrv_core.h
@@ -404,7 +404,7 @@ struct dcesrv_context {
/* the list of interfaces available on this endpoint */
struct dcesrv_if_list {
struct dcesrv_if_list *next, *prev;
- struct dcesrv_interface iface;
+ struct dcesrv_interface *iface;
} *interface_list;
/*
diff --git a/librpc/rpc/dcesrv_mgmt.c b/librpc/rpc/dcesrv_mgmt.c
index 80e78d56b0e..d75f08b56e6 100644
--- a/librpc/rpc/dcesrv_mgmt.c
+++ b/librpc/rpc/dcesrv_mgmt.c
@@ -58,7 +58,7 @@ static WERROR dcesrv_mgmt_inq_if_ids(struct dcesrv_call_state *dce_call, TALLOC_
for (l = ep->interface_list; l; l = l->next) {
vector->count++;
vector->if_id = talloc_realloc(mem_ctx, vector->if_id, struct ndr_syntax_id_p, vector->count);
- vector->if_id[vector->count-1].id = &l->iface.syntax_id;
+ vector->if_id[vector->count-1].id = &l->iface->syntax_id;
}
return WERR_OK;
}
@@ -119,7 +119,7 @@ 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)
+const struct dcesrv_interface *dcesrv_get_mgmt_interface(void)
{
- return dcesrv_mgmt_interface;
+ return &dcesrv_mgmt_interface;
}