Commit f20cfdfa authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

rpcrt4: Use RPCRT4_Receive rather than accessing the transport directly.

parent 9b3d8a35
...@@ -267,9 +267,8 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, ...@@ -267,9 +267,8 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
/* we need to send a binding packet if we are client. */ /* we need to send a binding packet if we are client. */
if (!(*Connection)->server) { if (!(*Connection)->server) {
RpcPktHdr *hdr; RpcPktHdr *hdr;
LONG count;
BYTE *response;
RpcPktHdr *response_hdr; RpcPktHdr *response_hdr;
RPC_MESSAGE msg;
TRACE("sending bind request to server\n"); TRACE("sending bind request to server\n");
...@@ -284,35 +283,17 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, ...@@ -284,35 +283,17 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
return status; return status;
} }
response = HeapAlloc(GetProcessHeap(), 0, RPC_MAX_PACKET_SIZE); status = RPCRT4_Receive(NewConnection, &response_hdr, &msg);
if (response == NULL) { if (status != RPC_S_OK) {
WARN("Can't allocate memory for binding response\n"); ERR("receive failed\n");
RPCRT4_DestroyConnection(*Connection);
return E_OUTOFMEMORY;
}
count = rpcrt4_conn_read(NewConnection, response, RPC_MAX_PACKET_SIZE);
if (count < sizeof(response_hdr->common)) {
WARN("received invalid header\n");
HeapFree(GetProcessHeap(), 0, response);
RPCRT4_DestroyConnection(*Connection);
return RPC_S_PROTOCOL_ERROR;
}
response_hdr = (RpcPktHdr*)response;
if (response_hdr->common.rpc_ver != RPC_VER_MAJOR ||
response_hdr->common.rpc_ver_minor != RPC_VER_MINOR ||
response_hdr->common.ptype != PKT_BIND_ACK) {
WARN("invalid protocol version or rejection packet\n");
HeapFree(GetProcessHeap(), 0, response);
RPCRT4_DestroyConnection(*Connection); RPCRT4_DestroyConnection(*Connection);
return RPC_S_PROTOCOL_ERROR; return status;
} }
if (response_hdr->bind_ack.max_tsize < RPC_MIN_PACKET_SIZE) { if (response_hdr->common.ptype != PKT_BIND_ACK ||
WARN("server doesn't allow large enough packets\n"); response_hdr->bind_ack.max_tsize < RPC_MIN_PACKET_SIZE) {
HeapFree(GetProcessHeap(), 0, response); ERR("failed to bind\n");
RPCRT4_FreeHeader(response_hdr);
RPCRT4_DestroyConnection(*Connection); RPCRT4_DestroyConnection(*Connection);
return RPC_S_PROTOCOL_ERROR; return RPC_S_PROTOCOL_ERROR;
} }
...@@ -321,7 +302,7 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection, ...@@ -321,7 +302,7 @@ RPC_STATUS RPCRT4_OpenBinding(RpcBinding* Binding, RpcConnection** Connection,
(*Connection)->MaxTransmissionSize = response_hdr->bind_ack.max_tsize; (*Connection)->MaxTransmissionSize = response_hdr->bind_ack.max_tsize;
(*Connection)->ActiveInterface = *InterfaceId; (*Connection)->ActiveInterface = *InterfaceId;
HeapFree(GetProcessHeap(), 0, response); RPCRT4_FreeHeader(response_hdr);
} }
Binding->FromConn = *Connection; Binding->FromConn = *Connection;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment