1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-23 09:57:40 +03:00

librpc/dcesrv_core: move two rpcint_dispatch() copies into dcesrv_call_dispatch_local()

We only need this function once, so that we need to fix bugs only once...

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14551

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
This commit is contained in:
Stefan Metzmacher 2020-10-23 11:42:14 +02:00 committed by Samuel Cabrero
parent 3b5b23ea84
commit 7c8a7e8a15
4 changed files with 67 additions and 128 deletions

View File

@ -2971,3 +2971,66 @@ _PUBLIC_ NTSTATUS dcesrv_connection_loop_start(struct dcesrv_connection *conn)
return NT_STATUS_OK;
}
_PUBLIC_ NTSTATUS dcesrv_call_dispatch_local(struct dcesrv_call_state *call)
{
NTSTATUS status;
struct ndr_pull *pull = NULL;
struct ndr_push *push = NULL;
struct data_blob_list_item *rep = NULL;
pull = ndr_pull_init_blob(&call->pkt.u.request.stub_and_verifier,
call);
if (pull == NULL) {
return NT_STATUS_NO_MEMORY;
}
pull->flags |= LIBNDR_FLAG_REF_ALLOC;
call->ndr_pull = pull;
/* unravel the NDR for the packet */
status = call->context->iface->ndr_pull(call, call, pull, &call->r);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("DCE/RPC fault in call %s:%02X - %s\n",
call->context->iface->name,
call->pkt.u.request.opnum,
dcerpc_errstr(call, call->fault_code));
return status;
}
status = call->context->iface->local(call, call, call->r);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("DCE/RPC fault in call %s:%02X - %s\n",
call->context->iface->name,
call->pkt.u.request.opnum,
dcerpc_errstr(call, call->fault_code));
return status;
}
push = ndr_push_init_ctx(call);
if (push == NULL) {
return NT_STATUS_NO_MEMORY;
}
push->ptr_count = call->ndr_pull->ptr_count;
status = call->context->iface->ndr_push(call, call, push, call->r);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("DCE/RPC fault in call %s:%02X - %s\n",
call->context->iface->name,
call->pkt.u.request.opnum,
dcerpc_errstr(call, call->fault_code));
return status;
}
rep = talloc_zero(call, struct data_blob_list_item);
if (rep == NULL) {
return NT_STATUS_NO_MEMORY;
}
rep->blob = ndr_push_blob(push);
DLIST_ADD_END(call->replies, rep);
return NT_STATUS_OK;
}

View File

@ -624,6 +624,8 @@ _PUBLIC_ void dcesrv_sock_report_output_data(struct dcesrv_connection *dce_conn)
_PUBLIC_ NTSTATUS dcesrv_connection_loop_start(struct dcesrv_connection *conn);
_PUBLIC_ NTSTATUS dcesrv_call_dispatch_local(struct dcesrv_call_state *call);
_PUBLIC_ const struct dcesrv_interface *find_interface_by_uuid(
const struct dcesrv_endpoint *endpoint,
const struct GUID *uuid, uint32_t if_version);

View File

@ -421,69 +421,6 @@ fail:
return status;
}
static NTSTATUS rpcint_dispatch(struct dcesrv_call_state *call)
{
NTSTATUS status;
struct ndr_pull *pull = NULL;
struct ndr_push *push = NULL;
struct data_blob_list_item *rep = NULL;
pull = ndr_pull_init_blob(&call->pkt.u.request.stub_and_verifier,
call);
if (pull == NULL) {
return NT_STATUS_NO_MEMORY;
}
pull->flags |= LIBNDR_FLAG_REF_ALLOC;
call->ndr_pull = pull;
/* unravel the NDR for the packet */
status = call->context->iface->ndr_pull(call, call, pull, &call->r);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("DCE/RPC fault in call %s:%02X - %s\n",
call->context->iface->name,
call->pkt.u.request.opnum,
dcerpc_errstr(call, call->fault_code));
return status;
}
status = call->context->iface->local(call, call, call->r);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("DCE/RPC fault in call %s:%02X - %s\n",
call->context->iface->name,
call->pkt.u.request.opnum,
dcerpc_errstr(call, call->fault_code));
return status;
}
push = ndr_push_init_ctx(call);
if (push == NULL) {
return NT_STATUS_NO_MEMORY;
}
push->ptr_count = call->ndr_pull->ptr_count;
status = call->context->iface->ndr_push(call, call, push, call->r);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("DCE/RPC fault in call %s:%02X - %s\n",
call->context->iface->name,
call->pkt.u.request.opnum,
dcerpc_errstr(call, call->fault_code));
return status;
}
rep = talloc_zero(call, struct data_blob_list_item);
if (rep == NULL) {
return NT_STATUS_NO_MEMORY;
}
rep->blob = ndr_push_blob(push);
DLIST_ADD_END(call->replies, rep);
return NT_STATUS_OK;
}
struct rpcint_bh_state {
struct dcesrv_connection *conn;
};
@ -567,7 +504,7 @@ static struct tevent_req *rpcint_bh_raw_call_send(TALLOC_CTX *mem_ctx,
state->call->pkt.u.request.stub_and_verifier.length = in_length;
/* TODO: allow async */
status = rpcint_dispatch(state->call);
status = dcesrv_call_dispatch_local(state->call);
if (!NT_STATUS_IS_OK(status)) {
tevent_req_nterror(req, status);
return tevent_req_post(req, ev);

View File

@ -475,69 +475,6 @@ struct dcerpc_binding_handle *wbint_binding_handle(TALLOC_CTX *mem_ctx,
return h;
}
static NTSTATUS rpcint_dispatch(struct dcesrv_call_state *call)
{
NTSTATUS status;
struct ndr_pull *pull = NULL;
struct ndr_push *push = NULL;
struct data_blob_list_item *rep = NULL;
pull = ndr_pull_init_blob(&call->pkt.u.request.stub_and_verifier,
call);
if (pull == NULL) {
return NT_STATUS_NO_MEMORY;
}
pull->flags |= LIBNDR_FLAG_REF_ALLOC;
call->ndr_pull = pull;
/* unravel the NDR for the packet */
status = call->context->iface->ndr_pull(call, call, pull, &call->r);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("DCE/RPC fault in call %s:%02X - %s\n",
call->context->iface->name,
call->pkt.u.request.opnum,
dcerpc_errstr(call, call->fault_code));
return status;
}
status = call->context->iface->local(call, call, call->r);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("DCE/RPC fault in call %s:%02X - %s\n",
call->context->iface->name,
call->pkt.u.request.opnum,
dcerpc_errstr(call, call->fault_code));
return status;
}
push = ndr_push_init_ctx(call);
if (push == NULL) {
return NT_STATUS_NO_MEMORY;
}
push->ptr_count = call->ndr_pull->ptr_count;
status = call->context->iface->ndr_push(call, call, push, call->r);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("DCE/RPC fault in call %s:%02X - %s\n",
call->context->iface->name,
call->pkt.u.request.opnum,
dcerpc_errstr(call, call->fault_code));
return status;
}
rep = talloc_zero(call, struct data_blob_list_item);
if (rep == NULL) {
return NT_STATUS_NO_MEMORY;
}
rep->blob = ndr_push_blob(push);
DLIST_ADD_END(call->replies, rep);
return NT_STATUS_OK;
}
enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
struct winbindd_cli_state *state)
{
@ -599,7 +536,7 @@ enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
data_blob_const(state->request->extra_data.data,
state->request->extra_len);
status = rpcint_dispatch(dcesrv_call);
status = dcesrv_call_dispatch_local(dcesrv_call);
if (!NT_STATUS_IS_OK(status)) {
goto out;
}