summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-04-08 10:49:03 -0700
committerJeremy Allison <jra@samba.org>2013-04-20 01:04:05 +0200
commit95f7fc83b251efefcc2a603b936b55e2f0308a72 (patch)
treedc950e9360920abf746847ae8acc013df40eb580 /source3
parent1ed710c2ffc91d8b33b87e572a6075e0126b5826 (diff)
downloadsamba-95f7fc83b251efefcc2a603b936b55e2f0308a72.tar.gz
samba-95f7fc83b251efefcc2a603b936b55e2f0308a72.tar.bz2
samba-95f7fc83b251efefcc2a603b936b55e2f0308a72.zip
Ensure the RECVFILE path in vfs_pwrite_data() operates on a blocking socket.
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat Apr 20 01:04:05 CEST 2013 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/vfs.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index dd74d79880..49609d0179 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -472,14 +472,25 @@ ssize_t vfs_pwrite_data(struct smb_request *req,
ssize_t ret;
if (req && req->unread_bytes) {
+ int sockfd = req->sconn->sock;
+ int old_flags;
SMB_ASSERT(req->unread_bytes == N);
/* VFS_RECVFILE must drain the socket
* before returning. */
req->unread_bytes = 0;
- return SMB_VFS_RECVFILE(req->sconn->sock,
+ /* Ensure the socket is blocking. */
+ old_flags = fcntl(sockfd, F_GETFL, 0);
+ if (set_blocking(sockfd, true) == -1) {
+ return (ssize_t)-1;
+ }
+ ret = SMB_VFS_RECVFILE(sockfd,
fsp,
offset,
N);
+ if (fcntl(sockfd, F_SETFL, old_flags) == -1) {
+ return (ssize_t)-1;
+ }
+ return ret;
}
while (total < N) {