Skip to content

close session when NewClient fails - #671

Merged
puellanivis merged 1 commit into
pkg:masterfrom
christhomas:fix-newclient-session-leak
Nov 5, 2026
Merged

puellanivis merged 1 commit into
pkg:masterfrom
christhomas:fix-newclient-session-leak

Conversation

@christhomas

Copy link
Copy Markdown
Contributor

Fixes #669

Closes the session on every error path in NewClient, as discussed in the issue.

The test runs a small SSH server that either refuses the subsystem, or accepts it and then the client fails on a bad option or a bad version packet, and checks that the session gets closed each time.

NewClient returned without closing the session it had opened when the
subsystem request, one of the pipes, or newClientPipe failed. Each
failed call left a session open until the connection was closed.

Fixes pkg#669
@puellanivis
puellanivis merged commit fc26a10 into pkg:master Nov 5, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NewClient leaves the SSH session open when it returns an error

2 participants