x/crypto/ssh: Channel.Read incorrectly returns write error instead of io.EOF #45912
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?go version go1.16.3 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Example:
https://play.golang.org/p/JAd3orfmiye
(The Go Playground sometimes sees the TCP dial/listen as a deadlock. It will often work though.)
What did you expect to see?
The data from the peer, then io.EOF.
What did you see instead?
Partial data, and a write-related error. Usually
write: broken pipe
orwrite: protocol wrong type for socket
More details
This only happens if the peer has closed the
ssh.Conn
(or the underlying transport). I believe the bug is rooted in an incorrect assumption here. The comment indicates that thechannel
should be tolerant of errors adjusting the window when the peer has closed the connection. The assumption is that such errors will be exclusivelyio.EOF
. Perhaps something has changed, but this is not currently the case.I'm actually not sure what the fix should be here as I'm not sure what error could be expected. I don't think
net.Conn.Write
makes any kind of guarantees about behavior when the peer has closed the connection. Somehow though, the buffered data should be returned to the reader, followed byio.EOF.
The text was updated successfully, but these errors were encountered: