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

request server: fix handles leak in error case #393

Merged
merged 1 commit into from
Nov 16, 2020
Merged

Conversation

drakkan
Copy link
Collaborator

@drakkan drakkan commented Nov 16, 2020

For open/opendir requests we create a new handle and close it
when the client sends an SSH_FXP_CLOSE but if we return an error the
client will never send the close packet so we have to close the handle
ourselves.

You can easily see the bug running the modified test cases without the patch.

The open handles will be closed when the client closes the whole connection, but if we have a client connected for a long time we accumulate handles every time we return an error for open/opendir.

This bug is more evident after applying #392 since the EOF will be converted to ErrUnexpectedEOF if open requests are found when the client disconnects

@drakkan drakkan added the bug label Nov 16, 2020
For open/opendir requests we create a new handle and close it
when the client sends an SSH_FXP_CLOSE but if we return an error the
client will never send the close packet so we have to close the handle
ourselves
@drakkan
Copy link
Collaborator Author

drakkan commented Nov 16, 2020

@puellanivis thank you for approving. What do you think about #392? After fixing the open connection tracking in this pull request #392 allows to return the correct exit status to the clients

@drakkan drakkan merged commit c30c93e into pkg:master Nov 16, 2020
drakkan added a commit to drakkan/sftpgo that referenced this pull request Nov 16, 2020
Include this patch:

pkg/sftp#393

to avoid request accumulation (no underlying fd) if we return an error.
Before this patch the accumulated requests are released only when the
client disconnects.

We use our fork for now to include

pkg/sftp#392

too
drakkan added a commit to drakkan/sftpgo that referenced this pull request Nov 18, 2020
These patches are now merged upstream:

pkg/sftp#392
pkg/sftp#393
@drakkan drakkan deleted the rsleak branch November 26, 2020 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants