Remove an unnecessary size check
authorVolker Lendecke <vl@samba.org>
Wed, 14 Jan 2009 11:58:38 +0000 (12:58 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 14 Jan 2009 16:08:39 +0000 (17:08 +0100)
rpc_read is only ever called with at most fraglen-RPC_HEADER_SIZE length

source3/rpc_client/cli_pipe.c

index 0a208bae36c96872503d1f92ef8b5f6f0ee3ac90..d9a94556b25acac2ae5a07cbd175db372731dd1a 100644 (file)
@@ -255,16 +255,15 @@ static bool rpc_grow_buffer(prs_struct *pdu, size_t size)
 
 static NTSTATUS rpc_read(struct rpc_pipe_client *cli,
                        prs_struct *current_pdu,
-                       uint32 data_to_read,
+                       size_t size,
                        uint32 *current_pdu_offset)
 {
-       size_t size = (size_t)cli->max_recv_frag;
        uint32 stream_offset = 0;
        ssize_t num_read = 0;
        char *pdata;
 
        DEBUG(5, ("rpc_read: data_to_read: %u current_pdu offset: %d\n",
-                 (unsigned int)data_to_read,
+                 (unsigned int)size,
                  (unsigned int)*current_pdu_offset));
 
        pdata = prs_data_p(current_pdu) + *current_pdu_offset;
@@ -272,11 +271,6 @@ static NTSTATUS rpc_read(struct rpc_pipe_client *cli,
        do {
                NTSTATUS status;
 
-               /* read data using SMBreadX */
-               if (size > (size_t)data_to_read) {
-                       size = (size_t)data_to_read;
-               }
-
                switch (cli->transport_type) {
                case NCACN_NP:
                        status = rpc_read_np(cli->trans.np.cli,
@@ -301,11 +295,11 @@ static NTSTATUS rpc_read(struct rpc_pipe_client *cli,
                        return NT_STATUS_INTERNAL_ERROR;
                }
 
-               data_to_read -= num_read;
+               size -= num_read;
                stream_offset += num_read;
                pdata += num_read;
 
-       } while (num_read > 0 && data_to_read > 0);
+       } while (num_read > 0 && size > 0);
        /* && err == (0x80000000 | STATUS_BUFFER_OVERFLOW)); */
 
        /*