From ff5a18ad3e5a9a4dac6947e3551126c8ea9077dd Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 22 Jun 2001 01:09:40 +0000 Subject: Merged cli_read_one() function for reading DCE/RPC reply fragments. (This used to be commit 9e074bc2bf2df34048b67457623bb8219fb1e4d6) --- source3/libsmb/clireadwrite.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'source3/libsmb') diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index 70266a2d9a..f5ddc77c8f 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -48,6 +48,52 @@ static void cli_issue_read(struct cli_state *cli, int fnum, off_t offset, cli_send_smb(cli); } +/**************************************************************************** + issue a single SMBread and wait for a reply. This function only called + in the rpc pipe code to read dce/rpc reply fragments. +****************************************************************************/ +size_t cli_read_one(struct cli_state *cli, int fnum, char *buf, off_t offset, + size_t size) +{ + uint32 ecode; + uint8 eclass; + char *p; + int size2; + + if (size == 0) + return 0; + + /* Issue a read and receive a reply */ + + cli_issue_read(cli, fnum, offset, size, 0); + + if (!cli_receive_smb(cli)) + return -1; + + size2 = SVAL(cli->inbuf, smb_vwv5); + + /* Check for error. Because the client library doesn't support + STATUS32, we need to check for and ignore the more data error + for pipe support. */ + + if (cli_error(cli, &eclass, &ecode, NULL) && + (eclass != ERRDOS && ecode != ERRmoredata)) { + return -1; + } + + if (size2 > size) { + DEBUG(5,("server returned more than we wanted!\n")); + return -1; + } + + /* Copy data into buffer */ + + p = smb_base(cli->inbuf) + SVAL(cli->inbuf,smb_vwv6); + memcpy(buf, p, size2); + + return size2; +} + /**************************************************************************** read from a file ****************************************************************************/ -- cgit