Make rpc_read look like a real read call
authorVolker Lendecke <vl@samba.org>
Wed, 14 Jan 2009 15:51:43 +0000 (16:51 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 14 Jan 2009 16:08:40 +0000 (17:08 +0100)
It doesn't really need to know about prs_structs

source3/rpc_client/cli_pipe.c

index fbd9b45a3a0884542f6b2e22eb3c4821d18714c8..99bd85af5d110986b02d4615288149d9281c1b91 100644 (file)
@@ -255,17 +255,11 @@ static bool rpc_grow_buffer(prs_struct *pdu, size_t size)
  ********************************************************************/
 
 static NTSTATUS rpc_read(struct rpc_pipe_client *cli,
-                       prs_struct *current_pdu,
-                       size_t size,
-                       uint32 current_pdu_offset)
+                        char *pdata, size_t size)
 {
        ssize_t num_read = 0;
-       char *pdata;
-
-       DEBUG(5, ("rpc_read: data_to_read: %u current_pdu offset: %d\n",
-                 (unsigned int)size, (unsigned int)current_pdu_offset));
 
-       pdata = prs_data_p(current_pdu) + current_pdu_offset;
+       DEBUG(5, ("rpc_read: data_to_read: %u\n", (unsigned int)size));
 
        while (num_read < size) {
                ssize_t thistime = 0;
@@ -295,13 +289,12 @@ static NTSTATUS rpc_read(struct rpc_pipe_client *cli,
                        return NT_STATUS_INTERNAL_ERROR;
                }
 
-               if (thistime == 0) {
-                       status = NT_STATUS_END_OF_FILE;
-               }
-
                if (!NT_STATUS_IS_OK(status)) {
                        return status;
                }
+               if (thistime == 0) {
+                       return NT_STATUS_END_OF_FILE;
+               }
 
                num_read += thistime;
 
@@ -325,9 +318,9 @@ static NTSTATUS cli_pipe_get_current_pdu(struct rpc_pipe_client *cli, RPC_HDR *p
                if (!rpc_grow_buffer(current_pdu, RPC_HEADER_LEN)) {
                        return NT_STATUS_NO_MEMORY;
                }
-               ret = rpc_read(cli, current_pdu,
-                              RPC_HEADER_LEN - current_pdu_len,
-                              current_pdu_len);
+               ret = rpc_read(cli,
+                              prs_data_p(current_pdu) + current_pdu_len,
+                              RPC_HEADER_LEN - current_pdu_len);
                if (!NT_STATUS_IS_OK(ret)) {
                        return ret;
                }
@@ -353,9 +346,9 @@ static NTSTATUS cli_pipe_get_current_pdu(struct rpc_pipe_client *cli, RPC_HDR *p
                if (!rpc_grow_buffer(current_pdu, prhdr->frag_len)) {
                        return NT_STATUS_NO_MEMORY;
                }
-               ret = rpc_read(cli, current_pdu,
-                              (uint32)prhdr->frag_len - current_pdu_len,
-                              current_pdu_len);
+               ret = rpc_read(cli,
+                              prs_data_p(current_pdu) + current_pdu_len,
+                              prhdr->frag_len - current_pdu_len);
                if (!NT_STATUS_IS_OK(ret)) {
                        return ret;
                }