Rob Shearman : rpcrt4: Make RpcAssoc_BindConnection use RPCRT4_ReceiveWithAuth instead of RPCRT4_Receive .

Alexandre Julliard julliard at winehq.org
Thu Jun 19 06:37:59 CDT 2008


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

Author: Rob Shearman <robertshearman at gmail.com>
Date:   Wed Jun 18 17:32:22 2008 +0100

rpcrt4: Make RpcAssoc_BindConnection use RPCRT4_ReceiveWithAuth instead of RPCRT4_Receive.

Move the special handling of the PKT_BIND_ACK packet from
RPCRT4_ReceiveWithAuth to RpcAssoc_BindConnection, where it belongs.

---

 dlls/rpcrt4/rpc_assoc.c   |   21 ++++++++++++++++-----
 dlls/rpcrt4/rpc_message.c |   14 ++------------
 dlls/rpcrt4/rpc_message.h |    1 +
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/dlls/rpcrt4/rpc_assoc.c b/dlls/rpcrt4/rpc_assoc.c
index 6075278..e8f3676 100644
--- a/dlls/rpcrt4/rpc_assoc.c
+++ b/dlls/rpcrt4/rpc_assoc.c
@@ -222,6 +222,8 @@ static RPC_STATUS RpcAssoc_BindConnection(const RpcAssoc *assoc, RpcConnection *
     RpcPktHdr *response_hdr;
     RPC_MESSAGE msg;
     RPC_STATUS status;
+    unsigned char *auth_data = NULL;
+    unsigned long auth_length;
 
     TRACE("sending bind request to server\n");
 
@@ -235,10 +237,10 @@ static RPC_STATUS RpcAssoc_BindConnection(const RpcAssoc *assoc, RpcConnection *
     if (status != RPC_S_OK)
         return status;
 
-    status = RPCRT4_Receive(conn, &response_hdr, &msg);
+    status = RPCRT4_ReceiveWithAuth(conn, &response_hdr, &msg, &auth_data, &auth_length);
     if (status != RPC_S_OK)
     {
-        ERR("receive failed\n");
+        ERR("receive failed with error %ld\n", status);
         return status;
     }
 
@@ -259,9 +261,17 @@ static RPC_STATUS RpcAssoc_BindConnection(const RpcAssoc *assoc, RpcConnection *
                 switch (results->results[0].result)
                 {
                 case RESULT_ACCEPT:
-                    conn->assoc_group_id = response_hdr->bind_ack.assoc_gid;
-                    conn->MaxTransmissionSize = response_hdr->bind_ack.max_tsize;
-                    conn->ActiveInterface = *InterfaceId;
+                    /* respond to authorization request */
+                    if (auth_length > sizeof(RpcAuthVerifier))
+                        status = RPCRT4_AuthorizeConnection(conn,
+                                                            auth_data + sizeof(RpcAuthVerifier),
+                                                            auth_length);
+                    if (status == RPC_S_OK)
+                    {
+                        conn->assoc_group_id = response_hdr->bind_ack.assoc_gid;
+                        conn->MaxTransmissionSize = response_hdr->bind_ack.max_tsize;
+                        conn->ActiveInterface = *InterfaceId;
+                    }
                     break;
                 case RESULT_PROVIDER_REJECTION:
                     switch (results->results[0].reason)
@@ -334,6 +344,7 @@ static RPC_STATUS RpcAssoc_BindConnection(const RpcAssoc *assoc, RpcConnection *
 
     I_RpcFree(msg.Buffer);
     RPCRT4_FreeHeader(response_hdr);
+    HeapFree(GetProcessHeap(), 0, auth_data);
     return status;
 }
 
diff --git a/dlls/rpcrt4/rpc_message.c b/dlls/rpcrt4/rpc_message.c
index fc89e2a..48c7df0 100644
--- a/dlls/rpcrt4/rpc_message.c
+++ b/dlls/rpcrt4/rpc_message.c
@@ -631,8 +631,8 @@ failed:
 /***********************************************************************
  *           RPCRT4_AuthorizeBinding (internal)
  */
-static RPC_STATUS RPCRT_AuthorizeConnection(RpcConnection* conn,
-                                            BYTE *challenge, ULONG count)
+RPC_STATUS RPCRT4_AuthorizeConnection(RpcConnection* conn, BYTE *challenge,
+                                      ULONG count)
 {
   SecBuffer inp, out;
   RpcPktHdr *resp_hdr;
@@ -948,16 +948,6 @@ RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header,
   }
   pMsg->BufferLength = buffer_length;
 
-  /* respond to authorization request */
-  if ((*Header)->common.ptype == PKT_BIND_ACK && auth_length > sizeof(RpcAuthVerifier))
-  {
-    status = RPCRT_AuthorizeConnection(Connection,
-                                       auth_data + sizeof(RpcAuthVerifier),
-                                       auth_length);
-    if (status)
-        goto fail;
-  }
-
   /* success */
   status = RPC_S_OK;
 
diff --git a/dlls/rpcrt4/rpc_message.h b/dlls/rpcrt4/rpc_message.h
index a9378fa..95eb807 100644
--- a/dlls/rpcrt4/rpc_message.h
+++ b/dlls/rpcrt4/rpc_message.h
@@ -37,5 +37,6 @@ RPC_STATUS RPCRT4_Receive(RpcConnection *Connection, RpcPktHdr **Header, PRPC_ME
 RPC_STATUS RPCRT4_ReceiveWithAuth(RpcConnection *Connection, RpcPktHdr **Header, PRPC_MESSAGE pMsg, unsigned char **auth_data_out, unsigned long *auth_length_out);
 NCA_STATUS RPC2NCA_STATUS(RPC_STATUS status);
 RPC_STATUS NCA2RPC_STATUS(NCA_STATUS status);
+RPC_STATUS RPCRT4_AuthorizeConnection(RpcConnection* conn, BYTE *challenge, ULONG count);
 
 #endif




More information about the wine-cvs mailing list