Skip to content

Commit

Permalink
sftp_readdir_async(): don't access request when it may have been freed
Browse files Browse the repository at this point in the history
Fixes: libfuse#7
  • Loading branch information
Nikratio committed Jul 12, 2017
1 parent 6f6491c commit 82766d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Unreleased Changes
------------------

* Fixed a crash due to a race condition when listing
directory contents.

Release 3.0.0 (2017-07-08)
--------------------------

Expand Down
7 changes: 6 additions & 1 deletion sshfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2073,11 +2073,16 @@ static int sftp_readdir_async(struct buffer *handle, void *buf, off_t offset,
outstanding--;

if (done) {
/* We need to cache want_reply, since processing
thread may free req right after unlock() if
want_reply == 0 */
int want_reply;
pthread_mutex_lock(&sshfs.lock);
if (sshfs_req_pending(req))
req->want_reply = 0;
want_reply = req->want_reply;
pthread_mutex_unlock(&sshfs.lock);
if (!req->want_reply)
if (!want_reply)
continue;
}

Expand Down

0 comments on commit 82766d1

Please sign in to comment.