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

Alexandre Julliard julliard at wine.codeweavers.com
Fri Nov 10 07:44:38 CST 2006


Module: wine
Branch: master
Commit: e0acc8d2767acc2159e01e4fca7364b0fba661a8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e0acc8d2767acc2159e01e4fca7364b0fba661a8

Author: Rob Shearman <rob at codeweavers.com>
Date:   Fri Nov 10 11:02:04 2006 +0000

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

---

 dlls/rpcrt4/rpc_server.c |   49 +++++++++++++++++++++++++++------------------
 1 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c
index 6a5f7ac..3efcc12 100644
--- a/dlls/rpcrt4/rpc_server.c
+++ b/dlls/rpcrt4/rpc_server.c
@@ -605,29 +605,31 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpW
 /***********************************************************************
  *             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);
 
   if (!ops)
-    return NULL;
+  {
+    FIXME("protseq %s not supported\n", debugstr_a(Protseq));
+    return RPC_S_PROTSEQ_NOT_SUPPORTED;
+  }
 
-  ps = ops->alloc();
-  if (!ps)
-    return NULL;
-  ps->MaxCalls = MaxCalls;
-  ps->Protseq = Protseq;
-  ps->Endpoint = Endpoint;
-  ps->ops = ops;
-  ps->MaxCalls = 0;
-  ps->conn = NULL;
-  InitializeCriticalSection(&ps->cs);
-  ps->is_listening = FALSE;
-  ps->mgr_mutex = NULL;
-  ps->server_ready_event = NULL;
+  *ps = ops->alloc();
+  if (!*ps)
+    return RPC_S_OUT_OF_RESOURCES;
+  (*ps)->MaxCalls = MaxCalls;
+  (*ps)->Protseq = Protseq;
+  (*ps)->Endpoint = Endpoint;
+  (*ps)->ops = ops;
+  (*ps)->MaxCalls = 0;
+  (*ps)->conn = NULL;
+  InitializeCriticalSection(&(*ps)->cs);
+  (*ps)->is_listening = FALSE;
+  (*ps)->mgr_mutex = NULL;
+  (*ps)->server_ready_event = NULL;
 
-  return ps;
+  return RPC_S_OK;
 }
 
 /***********************************************************************
@@ -638,12 +640,16 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpE
 {
   char *szps = (char*)Protseq, *szep = (char*)Endpoint;
   RpcServerProtseq* ps;
+  RPC_STATUS status;
 
   TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_a(szps), MaxCalls,
        debugstr_a(szep), SecurityDescriptor,
        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);
 }
@@ -655,13 +661,16 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpE
                                             PRPC_POLICY lpPolicy )
 {
   RpcServerProtseq* ps;
+  RPC_STATUS status;
 
   TRACE("(%s,%u,%s,%p,{%u,%lu,%lu})\n", debugstr_w( Protseq ), MaxCalls,
        debugstr_w( Endpoint ), SecurityDescriptor,
        lpPolicy->Length, lpPolicy->EndpointFlags, lpPolicy->NICFlags );
 
-  ps = alloc_serverprotoseq(MaxCalls, RPCRT4_strdupWtoA(Protseq),
-                            RPCRT4_strdupWtoA(Endpoint));
+  status = alloc_serverprotoseq(MaxCalls, RPCRT4_strdupWtoA(Protseq),
+                                RPCRT4_strdupWtoA(Endpoint), &ps);
+  if (status != RPC_S_OK)
+    return status;
 
   return RPCRT4_use_protseq(ps);
 }




More information about the wine-cvs mailing list