mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 07:10:53 +03:00
Detect end-of-stream in TransportImpl#init
OpenSSH will drop connections based on the value of MaxStartups when there are too many unauthenticated connection. When this happens, reads on the client socket return -1, which was previously inserted into the identification buffer, leading to the error in #118.
This commit is contained in:
@@ -158,7 +158,10 @@ public final class TransportImpl
|
||||
// Read server's ID
|
||||
final Buffer.PlainBuffer buf = new Buffer.PlainBuffer();
|
||||
while ((serverID = readIdentification(buf)).isEmpty()) {
|
||||
buf.putByte((byte) connInfo.in.read());
|
||||
int b = connInfo.in.read();
|
||||
if (b == -1)
|
||||
throw new TransportException("Server closed connection during identification exchange");
|
||||
buf.putByte((byte) b);
|
||||
}
|
||||
|
||||
log.info("Server identity string: {}", serverID);
|
||||
|
||||
Reference in New Issue
Block a user