diff options
author | Jeremy Allison <jra@samba.org> | 2013-04-08 10:32:10 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-04-19 14:11:27 -0700 |
commit | 1ed710c2ffc91d8b33b87e572a6075e0126b5826 (patch) | |
tree | 811f53a4378eed727602d9f3652a76749e4bc5c5 /source3 | |
parent | 1b46db7b24a4f064706c2c7e712452135a3fed34 (diff) | |
download | samba-1ed710c2ffc91d8b33b87e572a6075e0126b5826.tar.gz samba-1ed710c2ffc91d8b33b87e572a6075e0126b5826.tar.bz2 samba-1ed710c2ffc91d8b33b87e572a6075e0126b5826.zip |
Ensure the RECVFILE path in vfs_write_data() operates on a blocking socket.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan (metze) Metzmacher <metze@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/vfs.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 856e090ed3..dd74d79880 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -428,14 +428,25 @@ ssize_t vfs_write_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, (off_t)-1, N); + if (fcntl(sockfd, F_SETFL, old_flags) == -1) { + return (ssize_t)-1; + } + return ret; } while (total < N) { |