summaryrefslogtreecommitdiff
path: root/source3/rpc_client
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-01-14 16:06:10 +0100
committerVolker Lendecke <vl@samba.org>2009-01-14 17:08:39 +0100
commit11e3388083be7a1be7854cab1603f2dc2905032e (patch)
tree8d22528c89bfba88af6bb1cf3007e5e48605ba2f /source3/rpc_client
parent15dd11b31eac52ffe216efc60129980c9fc3f052 (diff)
downloadsamba-11e3388083be7a1be7854cab1603f2dc2905032e.tar.gz
samba-11e3388083be7a1be7854cab1603f2dc2905032e.tar.bz2
samba-11e3388083be7a1be7854cab1603f2dc2905032e.zip
Simplify rpc_read a bit
rpc_read always reads the whole bytes it was asked to read. So it is not really necessary for it to update the current_pdu_offset, for clarity this can better be done in the caller.
Diffstat (limited to 'source3/rpc_client')
-rw-r--r--source3/rpc_client/cli_pipe.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index d9a94556b2..d5d0388107 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -251,22 +251,21 @@ static bool rpc_grow_buffer(prs_struct *pdu, size_t size)
/*******************************************************************
Use SMBreadX to get rest of one fragment's worth of rpc data.
+ Reads the whole size or give an error message
********************************************************************/
static NTSTATUS rpc_read(struct rpc_pipe_client *cli,
prs_struct *current_pdu,
size_t size,
- uint32 *current_pdu_offset)
+ uint32 current_pdu_offset)
{
- 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)size,
- (unsigned int)*current_pdu_offset));
+ (unsigned int)size, (unsigned int)current_pdu_offset));
- pdata = prs_data_p(current_pdu) + *current_pdu_offset;
+ pdata = prs_data_p(current_pdu) + current_pdu_offset;
do {
NTSTATUS status;
@@ -296,16 +295,11 @@ static NTSTATUS rpc_read(struct rpc_pipe_client *cli,
}
size -= num_read;
- stream_offset += num_read;
pdata += num_read;
} while (num_read > 0 && size > 0);
/* && err == (0x80000000 | STATUS_BUFFER_OVERFLOW)); */
- /*
- * Update the current offset into current_pdu by the amount read.
- */
- *current_pdu_offset += stream_offset;
return NT_STATUS_OK;
}
@@ -324,10 +318,13 @@ 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, current_pdu,
+ RPC_HEADER_LEN - current_pdu_len,
+ current_pdu_len);
if (!NT_STATUS_IS_OK(ret)) {
return ret;
}
+ current_pdu_len = RPC_HEADER_LEN;
}
/* This next call sets the endian bit correctly in current_pdu. */
@@ -349,16 +346,14 @@ 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, current_pdu,
+ (uint32)prhdr->frag_len - current_pdu_len,
+ current_pdu_len);
if (!NT_STATUS_IS_OK(ret)) {
return ret;
}
}
- if (current_pdu_len < prhdr->frag_len) {
- return NT_STATUS_BUFFER_TOO_SMALL;
- }
-
return NT_STATUS_OK;
}