diff options
author | Volker Lendecke <vl@samba.org> | 2009-05-02 11:31:37 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2009-05-05 13:44:47 -0700 |
commit | 386a5d99b32fa1296618f59f9a9072d9faf2c8ac (patch) | |
tree | b66cfb6a4a59deb2edb17cf6df0974cad1660185 /source3/smbd | |
parent | fee4c99be494b9679c414d6ba1938aa88adeacd3 (diff) | |
download | samba-386a5d99b32fa1296618f59f9a9072d9faf2c8ac.tar.gz samba-386a5d99b32fa1296618f59f9a9072d9faf2c8ac.tar.bz2 samba-386a5d99b32fa1296618f59f9a9072d9faf2c8ac.zip |
Fix bug 6302: Give the VFS a chance to read from 0-byte files
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/reply.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index d2e1f8be5f..418c8ba788 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3358,14 +3358,13 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req, return; } - if (startpos > sbuf.st_size) { - smb_maxcnt = 0; - } else if (smb_maxcnt > (sbuf.st_size - startpos)) { - smb_maxcnt = (sbuf.st_size - startpos); - } - - if (smb_maxcnt == 0) { - goto normal_read; + if (!S_ISREG(sbuf.st_mode) || (startpos > sbuf.st_size) + || (smb_maxcnt > (sbuf.st_size - startpos))) { + /* + * We already know that we would do a short read, so don't + * try the sendfile() path. + */ + goto nosendfile_read; } #if defined(WITH_SENDFILE) @@ -3482,6 +3481,8 @@ normal_read: return; } +nosendfile_read: + reply_outbuf(req, 12, smb_maxcnt); nread = read_file(fsp, smb_buf(req->outbuf), startpos, smb_maxcnt); |