diff options
Diffstat (limited to 'common-session.c')
-rw-r--r-- | common-session.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/common-session.c b/common-session.c index 3d759b5..8b882e1 100644 --- a/common-session.c +++ b/common-session.c @@ -64,6 +64,7 @@ void common_session_init(int sock_in, int sock_out, char* remotehost) { ses.connect_time = 0; ses.last_packet_time = 0; + ses.last_recv_packet_time = 0; if (pipe(ses.signal_pipe) < 0) { dropbear_exit("signal pipe failed"); @@ -256,7 +257,7 @@ void session_identification() { ses.remoteclosed(); } - /* If they send more than 50 lines, something is wrong */ + /* If they send more than 50 lines, something is wrong */ for (i = 0; i < 50; i++) { len = ident_readln(ses.sock_in, linebuf, sizeof(linebuf)); @@ -281,11 +282,11 @@ void session_identification() { memcpy(ses.remoteident, linebuf, len); } - /* Shall assume that 2.x will be backwards compatible. */ - if (strncmp(ses.remoteident, "SSH-2.", 6) != 0 - && strncmp(ses.remoteident, "SSH-1.99-", 9) != 0) { - dropbear_exit("Incompatible remote version '%s'", ses.remoteident); - } + /* Shall assume that 2.x will be backwards compatible. */ + if (strncmp(ses.remoteident, "SSH-2.", 6) != 0 + && strncmp(ses.remoteident, "SSH-1.99-", 9) != 0) { + dropbear_exit("Incompatible remote version '%s'", ses.remoteident); + } TRACE(("remoteident: %s", ses.remoteident)) @@ -400,6 +401,11 @@ static void checktimeouts() { && now - ses.last_packet_time >= opts.keepalive_secs) { send_msg_ignore(); } + + if (opts.idle_timeout_secs > 0 && ses.last_recv_packet_time > 0 + && now - ses.last_recv_packet_time >= opts.idle_timeout_secs) { + dropbear_close("Idle timeout"); + } } static long select_timeout() { @@ -412,6 +418,8 @@ static long select_timeout() { ret = MIN(AUTH_TIMEOUT, ret); if (opts.keepalive_secs > 0) ret = MIN(opts.keepalive_secs, ret); + if (opts.idle_timeout_secs > 0) + ret = MIN(opts.idle_timeout_secs, ret); return ret; } |