Bug 1375 - sftp-client leaks handles on failure to open local file
Summary: sftp-client leaks handles on failure to open local file
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: 4.7p1
Hardware: All All
: P2 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_4_8
  Show dependency treegraph
 
Reported: 2007-10-16 04:20 AEST by Scott Worley
Modified: 2008-03-31 15:21 AEDT (History)
1 user (show)

See Also:


Attachments
do_close(handle) on local file open failure (570 bytes, patch)
2007-10-16 04:20 AEST, Scott Worley
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Worley 2007-10-16 04:20:03 AEST
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.
Comment 1 Damien Miller 2008-01-20 09:05:15 AEDT
fix applied - thanks!
Comment 2 Damien Miller 2008-03-31 15:21:43 AEDT
Fix shipped in 4.9/4.9p1 release.