Created attachment 1362 [details] do_close(handle) on local file open failure I get "Couldn't get handle: Failure" after N failures to open local files for writing where N = 100 on OpenBSD and N = 200 on GNU/Linux. To reproduce: bash-3.2$ ssh otherhost otherhost$ mkdir test otherhost$ cd test otherhost$ touch {1000..1120} otherhost$ logout Connection to otherhost closed. bash-3.2$ mkdir test bash-3.2$ cd test bash-3.2$ touch {1000..1110} bash-3.2$ chmod 400 * bash-3.2$ sftp otherhost Connecting to otherhost... sftp> cd test sftp> get * Fetching /home/user/test/1000 to 1000 Couldn't open local file "1000" for writing: Permission denied Fetching /home/user/test/1001 to 1001 Couldn't open local file "1001" for writing: Permission denied ... Fetching /home/user/test/1099 to 1099 Couldn't open local file "1099" for writing: Permission denied Fetching /home/user/test/1100 to 1100 Couldn't get handle: Failure Fetching /home/user/test/1101 to 1101 Couldn't get handle: Failure ... Fetching /home/user/test/1120 to 1120 Couldn't get handle: Failure sftp> ls Couldn't get handle: Failure The attached patch seems to fix the problem.
fix applied - thanks!
Fix shipped in 4.9/4.9p1 release.