From 5dadbdf55657f9cc5e15e9fae5c30142b7fdbf45 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 17 Feb 2019 19:09:38 +0000 Subject: [PATCH] ssh_sftp_do_select: don't fail if a callback is pending. ssh_sftp_loop_iteration() used to return failure if no file handle was in use for the select loop, on the basis that that means select would just loop forever. But if there's a toplevel callback pending - in particular, if it's going to do something like emptying ssh->in_raw which will put an fd _back into_ the next iteration of the select loop - then that's not a good enough reason to return permanent failure. Just go round the loop, run the callback, and try again. --- unix/uxsftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/uxsftp.c b/unix/uxsftp.c index 1563cfb7..81691e70 100644 --- a/unix/uxsftp.c +++ b/unix/uxsftp.c @@ -463,7 +463,7 @@ static int ssh_sftp_do_select(bool include_stdin, bool no_fds_ok) for (fd = first_fd(&fdstate, &rwx); fd >= 0; fd = next_fd(&fdstate, &rwx)) i++; - if (i < 1 && !no_fds_ok) + if (i < 1 && !no_fds_ok && !toplevel_callback_pending()) return -1; /* doom */ /* Expand the fdlist buffer if necessary. */