Jacek Caban : rpcrt4: Simplify rpcrt4_conn_np_read implementation.

Alexandre Julliard julliard at winehq.org
Mon May 22 15:54:04 CDT 2017


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon May 22 16:04:02 2017 +0200

rpcrt4: Simplify rpcrt4_conn_np_read implementation.

Since RPC messages are sent as a single message, if it's too short, it
means the message is broken and we let the caller to handle an error.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/rpcrt4/rpc_transport.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c
index bc2f4a3..6fa1e60 100644
--- a/dlls/rpcrt4/rpc_transport.c
+++ b/dlls/rpcrt4/rpc_transport.c
@@ -409,24 +409,14 @@ static RPC_STATUS rpcrt4_ncalrpc_handoff(RpcConnection *old_conn, RpcConnection
   return status;
 }
 
-static int rpcrt4_conn_np_read(RpcConnection *Connection,
-                        void *buffer, unsigned int count)
+static int rpcrt4_conn_np_read(RpcConnection *conn, void *buffer, unsigned int count)
 {
-  RpcConnection_np *npc = (RpcConnection_np *) Connection;
-  IO_STATUS_BLOCK io_status;
-  char *buf = buffer;
-  unsigned int bytes_left = count;
-  NTSTATUS status;
+    RpcConnection_np *connection = (RpcConnection_np *) conn;
+    IO_STATUS_BLOCK io_status;
+    NTSTATUS status;
 
-  while (bytes_left)
-  {
-    status = NtReadFile(npc->pipe, NULL, NULL, NULL, &io_status, buf, bytes_left, NULL, NULL);
-    if (status && status != STATUS_BUFFER_OVERFLOW)
-      return -1;
-    bytes_left -= io_status.Information;
-    buf += io_status.Information;
-  }
-  return count;
+    status = NtReadFile(connection->pipe, NULL, NULL, NULL, &io_status, buffer, count, NULL, NULL);
+    return status && status != STATUS_BUFFER_OVERFLOW ? -1 : io_status.Information;
 }
 
 static int rpcrt4_conn_np_write(RpcConnection *conn, const void *buffer, unsigned int count)




More information about the wine-cvs mailing list