rpcrt4: Fix a crash in RpcServerUseProtseqEpExA/W when using an unsupported protseq.

This commit is contained in:
Rob Shearman 2006-11-10 11:02:04 +00:00 committed by Alexandre Julliard
parent 44922d29db
commit e0acc8d276
1 changed files with 29 additions and 20 deletions

View File

@ -605,29 +605,31 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpW( RPC_WSTR Protseq, UINT MaxCalls, RPC_W
/*********************************************************************** /***********************************************************************
* alloc_serverprotoseq (internal) * alloc_serverprotoseq (internal)
*/ */
static RpcServerProtseq *alloc_serverprotoseq(UINT MaxCalls, char *Protseq, char *Endpoint) static RPC_STATUS alloc_serverprotoseq(UINT MaxCalls, char *Protseq, char *Endpoint, RpcServerProtseq **ps)
{ {
RpcServerProtseq* ps;
const struct protseq_ops *ops = rpcrt4_get_protseq_ops(Protseq); const struct protseq_ops *ops = rpcrt4_get_protseq_ops(Protseq);
if (!ops) if (!ops)
return NULL; {
FIXME("protseq %s not supported\n", debugstr_a(Protseq));
return RPC_S_PROTSEQ_NOT_SUPPORTED;
}
ps = ops->alloc(); *ps = ops->alloc();
if (!ps) if (!*ps)
return NULL; return RPC_S_OUT_OF_RESOURCES;
ps->MaxCalls = MaxCalls; (*ps)->MaxCalls = MaxCalls;
ps->Protseq = Protseq; (*ps)->Protseq = Protseq;
ps->Endpoint = Endpoint; (*ps)->Endpoint = Endpoint;
ps->ops = ops; (*ps)->ops = ops;
ps->MaxCalls = 0; (*ps)->MaxCalls = 0;
ps->conn = NULL; (*ps)->conn = NULL;
InitializeCriticalSection(&ps->cs); InitializeCriticalSection(&(*ps)->cs);
ps->is_listening = FALSE; (*ps)->is_listening = FALSE;
ps->mgr_mutex = NULL; (*ps)->mgr_mutex = NULL;
ps->server_ready_event = NULL; (*ps)->server_ready_event = NULL;
return ps; return RPC_S_OK;
} }
/*********************************************************************** /***********************************************************************
@ -638,12 +640,16 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpExA( RPC_CSTR Protseq, UINT MaxCalls, RPC
{ {
char *szps = (char*)Protseq, *szep = (char*)Endpoint; char *szps = (char*)Protseq, *szep = (char*)Endpoint;
RpcServerProtseq* ps; RpcServerProtseq* ps;
RPC_STATUS status;
TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_a(szps), MaxCalls, TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_a(szps), MaxCalls,
debugstr_a(szep), SecurityDescriptor, debugstr_a(szep), SecurityDescriptor,
lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags ); lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags );
ps = alloc_serverprotoseq(MaxCalls, RPCRT4_strdupA(szps), RPCRT4_strdupA(szep)); status = alloc_serverprotoseq(MaxCalls, RPCRT4_strdupA(szps),
RPCRT4_strdupA(szep), &ps);
if (status != RPC_S_OK)
return status;
return RPCRT4_use_protseq(ps); return RPCRT4_use_protseq(ps);
} }
@ -655,13 +661,16 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpExW( RPC_WSTR Protseq, UINT MaxCalls, RPC
PRPC_POLICY lpPolicy ) PRPC_POLICY lpPolicy )
{ {
RpcServerProtseq* ps; RpcServerProtseq* ps;
RPC_STATUS status;
TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_w( Protseq ), MaxCalls, TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_w( Protseq ), MaxCalls,
debugstr_w( Endpoint ), SecurityDescriptor, debugstr_w( Endpoint ), SecurityDescriptor,
lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags ); lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags );
ps = alloc_serverprotoseq(MaxCalls, RPCRT4_strdupWtoA(Protseq), status = alloc_serverprotoseq(MaxCalls, RPCRT4_strdupWtoA(Protseq),
RPCRT4_strdupWtoA(Endpoint)); RPCRT4_strdupWtoA(Endpoint), &ps);
if (status != RPC_S_OK)
return status;
return RPCRT4_use_protseq(ps); return RPCRT4_use_protseq(ps);
} }