Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket handles are leaked when a data transfer is in progress and user QUITs #71

Closed
giampaolo opened this issue May 28, 2014 · 6 comments
Labels
bug Component-Library imported imported from old googlecode site and very likely outdated Security

Comments

@giampaolo
Copy link
Owner

From Rauli.Ru...@gmail.com on June 26, 2008 17:03:39

What steps will reproduce the problem?  
1. Start an ftp server as in quick start at 
https://code.google.com/p/pyftpdlib/ .
2. Look at the file handles opened by Python (in Linux, find out the
process id and ls -l /proc/processid/fd).
3. Connect to the server using an ftp client that opens an active data
connection before STOR (at least Linux's plain "ftp" does this).
4. Try to put a file, getting a 550 error. Quit.
5. Look at the file handles again. Notice that some sockets were not closed.

Repeat steps 3-5 to increase used socket handles as much as you want.
Eventually this will hit the system file handle limit, causing the ftp
server to become inoperative.

The bug will not occur if the ftp client closes the connection abruptly,
e.g. if you kill -9 the ftp client process.

Example snippet for steps 3-4 from an ftp client:

ftp> put 123
local: 123 remote: 123
200 Active data connection established.
550 Can't STOR. Not enough privileges.
ftp> quit
221 Goodbye. 

What is the expected output?  


What do you see instead?  
See above.

What version of pyftpdlib are you using? On what operating system? Which
Python version?

Pyftpdlib 0.4.0, on Ubuntu hardy, with Python 2.5.2. 

Please provide any additional information below.  
Adding the following to ftpserver.py's ftp_QUIT fixes this:

+        if not self.data_channel.transfer_in_progress():
+            self.data_channel.close()
+            self.data_channel = None
        if not self.data_channel:
            self.close_when_done()
        else:
            # tell the cmd channel to stop responding to commands.
            self.quit_pending = True

Original issue: http://code.google.com/p/pyftpdlib/issues/detail?id=71

@giampaolo
Copy link
Owner Author

From Rauli.Ru...@gmail.com on June 26, 2008 08:08:01

Err, of course you have to check that self.data_channel is not None before calling
the transfer_in_progress method :-)

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on June 26, 2008 18:11:55

Thanks for the report.
Patch applied in r334 .

Summary: Socket handles are leaked when a data transfer is in progress and user QUITs
Status: Finished
Labels: Version-0.4.0 Milestone-0.4.1 OpSys-Linux Security

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on June 26, 2008 18:13:43

Sorry, I meant r344 .

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on July 18, 2008 03:48:06

Labels: Milestone-0.5.0

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on September 20, 2008 11:15:03

Fixed/Implemented in version 0.5.0 which is released now.

Status: Fixed

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on October 13, 2008 12:13:14

Labels: Component-Library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Component-Library imported imported from old googlecode site and very likely outdated Security
Projects
None yet
Development

No branches or pull requests

1 participant