summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-08-12 12:57:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:29:32 -0500
commit5d39acf2f8cdee9e70a470a638909db7ceb219b2 (patch)
tree6ea0085ec20931d966932e21e978ccf135c29ca9 /source3/smbd
parent2fb27fcb692dfaccf36c6530012d6e24f944e1a4 (diff)
downloadsamba-5d39acf2f8cdee9e70a470a638909db7ceb219b2.tar.gz
samba-5d39acf2f8cdee9e70a470a638909db7ceb219b2.tar.bz2
samba-5d39acf2f8cdee9e70a470a638909db7ceb219b2.zip
r24351: Remove reply_prep_legacy from reply_read_and_X
(This used to be commit 8f3e3a21008a2cb6ed73d8629aaf1fa565f19e79)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/reply.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 1698a0e7b1..bf09180529 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -2728,12 +2728,14 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
Setup readX header.
****************************************************************************/
-static int setup_readX_header(char *inbuf, char *outbuf, size_t smb_maxcnt)
+static int setup_readX_header(const uint8 *inbuf, uint8 *outbuf,
+ size_t smb_maxcnt)
{
int outsize;
char *data;
- outsize = set_message(inbuf, outbuf,12,smb_maxcnt,False);
+ outsize = set_message((char *)inbuf, (char *)outbuf,12,smb_maxcnt,
+ False);
data = smb_buf(outbuf);
SSVAL(outbuf,smb_vwv2,0xFFFF); /* Remaining - must be -1. */
@@ -2757,9 +2759,6 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
{
SMB_STRUCT_STAT sbuf;
ssize_t nread = -1;
- char *data;
- char *inbuf, *outbuf;
- int length, len_outbuf;
if(SMB_VFS_FSTAT(fsp,fsp->fh->fd, &sbuf) == -1) {
reply_unixerror(req, ERRDOS, ERRnoaccess);
@@ -2785,7 +2784,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
if ((chain_size == 0) && (CVAL(req->inbuf,smb_vwv0) == 0xFF) &&
lp_use_sendfile(SNUM(conn)) && (fsp->wcp == NULL) ) {
- char headerbuf[smb_size + 12 * 2];
+ uint8 headerbuf[smb_size + 12 * 2];
DATA_BLOB header;
/*
@@ -2796,8 +2795,8 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
header = data_blob_const(headerbuf, sizeof(headerbuf));
- construct_reply_common((char *)req->inbuf, headerbuf);
- setup_readX_header((char *)req->inbuf, headerbuf, smb_maxcnt);
+ construct_reply_common((char *)req->inbuf, (char *)headerbuf);
+ setup_readX_header(req->inbuf, headerbuf, smb_maxcnt);
if ((nread = SMB_VFS_SENDFILE( smbd_server_fd(), fsp, fsp->fh->fd, &header, startpos, smb_maxcnt)) == -1) {
/* Returning ENOSYS means no data at all was sent. Do this as a normal read. */
@@ -2845,19 +2844,15 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
normal_read:
- if (!reply_prep_legacy(req, &inbuf, &outbuf, &length, &len_outbuf)) {
- reply_nterror(req, NT_STATUS_NO_MEMORY);
- return;
- }
-
- set_message(inbuf, outbuf, 12, 0, True);
+ if ((smb_maxcnt & 0xFF0000) > 0x10000) {
+ uint8 headerbuf[smb_size + 2*12];
- data = smb_buf(outbuf);
+ construct_reply_common((char *)req->inbuf, (char *)headerbuf);
+ setup_readX_header(req->inbuf, headerbuf, smb_maxcnt);
- if ((smb_maxcnt & 0xFF0000) > 0x10000) {
- int sendlen = setup_readX_header(inbuf,outbuf,smb_maxcnt) - smb_maxcnt;
/* Send out the header. */
- if (write_data(smbd_server_fd(),outbuf,sendlen) != sendlen) {
+ if (write_data(smbd_server_fd(), (char *)headerbuf,
+ sizeof(headerbuf)) != sizeof(headerbuf)) {
DEBUG(0,("send_file_readX: write_data failed for file %s (%s). Terminating\n",
fsp->fsp_name, strerror(errno) ));
exit_server_cleanly("send_file_readX sendfile failed");
@@ -2871,14 +2866,16 @@ normal_read:
TALLOC_FREE(req->outbuf);
return;
} else {
- nread = read_file(fsp,data,startpos,smb_maxcnt);
+ reply_outbuf(req, 12, smb_maxcnt);
+ nread = read_file(fsp, smb_buf(req->outbuf), startpos,
+ smb_maxcnt);
if (nread < 0) {
reply_unixerror(req, ERRDOS, ERRnoaccess);
return;
}
- setup_readX_header(inbuf, outbuf,nread);
+ setup_readX_header(req->inbuf, req->outbuf, nread);
DEBUG( 3, ( "send_file_readX fnum=%d max=%d nread=%d\n",
fsp->fnum, (int)smb_maxcnt, (int)nread ) );