diff options
author | Tim Prouty <tprouty@samba.org> | 2009-05-18 18:20:18 -0700 |
---|---|---|
committer | Tim Prouty <tprouty@samba.org> | 2009-05-18 18:31:02 -0700 |
commit | c3bc83314080cd5296f55fa30a8d406593877636 (patch) | |
tree | e2a0d7768a9a3f028debc1918b77c04ea64a9e50 | |
parent | 518666102367ce21782cb0f597c136ac125cef05 (diff) | |
download | samba-c3bc83314080cd5296f55fa30a8d406593877636.tar.gz samba-c3bc83314080cd5296f55fa30a8d406593877636.tar.bz2 samba-c3bc83314080cd5296f55fa30a8d406593877636.zip |
s3 sendfile: Fix two bugs in sendfile
These were found interally via code inspection.
1) fake_sendfile was incorrectly writing zeros over real data on a
short read.
2) sendfile_short_send was doing 4 byte writes instead of 1024 byte
writes due to an incorrect sizeof usage.
Jermey, Vl please check
-rw-r--r-- | source3/smbd/reply.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index a81c22b750..879550bb2e 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2757,7 +2757,7 @@ static ssize_t fake_sendfile(files_struct *fsp, SMB_OFF_T startpos, /* If we had a short read, fill with zeros. */ if (ret < cur_read) { - memset(buf, '\0', cur_read - ret); + memset(buf + ret, '\0', cur_read - ret); } if (write_data(smbd_server_fd(),buf,cur_read) != cur_read) { @@ -2783,6 +2783,7 @@ static void sendfile_short_send(files_struct *fsp, size_t headersize, size_t smb_maxcnt) { +#define SHORT_SEND_BUFSIZE 1024 if (nread < headersize) { DEBUG(0,("sendfile_short_send: sendfile failed to send " "header for file %s (%s). Terminating\n", @@ -2793,7 +2794,7 @@ static void sendfile_short_send(files_struct *fsp, nread -= headersize; if (nread < smb_maxcnt) { - char *buf = SMB_CALLOC_ARRAY(char, 1024); + char *buf = SMB_CALLOC_ARRAY(char, SHORT_SEND_BUFSIZE); if (!buf) { exit_server_cleanly("sendfile_short_send: " "malloc failed"); @@ -2819,7 +2820,7 @@ static void sendfile_short_send(files_struct *fsp, */ size_t to_write; - to_write = MIN(sizeof(buf), smb_maxcnt - nread); + to_write = MIN(SHORT_SEND_BUFSIZE, smb_maxcnt - nread); if (write_data(smbd_server_fd(), buf, to_write) != to_write) { exit_server_cleanly("sendfile_short_send: " "write_data failed"); |