Mercurial > dropbear
comparison common-session.c @ 1318:10e2a7727253 coverity
merge coverity
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 22 Jul 2016 00:08:02 +0800 |
parents | 2c9dac2d6707 |
children | 08f4fa4dc6a0 0c16b4ccbd54 |
comparison
equal
deleted
inserted
replaced
1286:7d02b83c61fd | 1318:10e2a7727253 |
---|---|
52 | 52 |
53 /* called only at the start of a session, set up initial state */ | 53 /* called only at the start of a session, set up initial state */ |
54 void common_session_init(int sock_in, int sock_out) { | 54 void common_session_init(int sock_in, int sock_out) { |
55 time_t now; | 55 time_t now; |
56 | 56 |
57 #ifdef DEBUG_TRACE | 57 #if DEBUG_TRACE |
58 debug_start_net(); | 58 debug_start_net(); |
59 #endif | 59 #endif |
60 | 60 |
61 TRACE(("enter session_init")) | 61 TRACE(("enter session_init")) |
62 | 62 |
293 if (ses.extra_session_cleanup) { | 293 if (ses.extra_session_cleanup) { |
294 ses.extra_session_cleanup(); | 294 ses.extra_session_cleanup(); |
295 } | 295 } |
296 | 296 |
297 /* After these are freed most functions will fail */ | 297 /* After these are freed most functions will fail */ |
298 #ifdef DROPBEAR_CLEANUP | 298 #if DROPBEAR_CLEANUP |
299 /* listeners call cleanup functions, this should occur before | 299 /* listeners call cleanup functions, this should occur before |
300 other session state is freed. */ | 300 other session state is freed. */ |
301 remove_all_listeners(); | 301 remove_all_listeners(); |
302 | 302 |
303 remove_connect_pending(); | 303 remove_connect_pending(); |
359 break; | 359 break; |
360 } | 360 } |
361 } | 361 } |
362 | 362 |
363 if (!done) { | 363 if (!done) { |
364 TRACE(("err: %s for '%s'\n", strerror(errno), linebuf)) | 364 TRACE(("error reading remote ident: %s\n", strerror(errno))) |
365 ses.remoteclosed(); | 365 ses.remoteclosed(); |
366 } else { | 366 } else { |
367 /* linebuf is already null terminated */ | 367 /* linebuf is already null terminated */ |
368 ses.remoteident = m_malloc(len); | 368 ses.remoteident = m_malloc(len); |
369 memcpy(ses.remoteident, linebuf, len); | 369 memcpy(ses.remoteident, linebuf, len); |
548 } | 548 } |
549 | 549 |
550 static long select_timeout() { | 550 static long select_timeout() { |
551 /* determine the minimum timeout that might be required, so | 551 /* determine the minimum timeout that might be required, so |
552 as to avoid waking when unneccessary */ | 552 as to avoid waking when unneccessary */ |
553 long timeout = LONG_MAX; | 553 long timeout = KEX_REKEY_TIMEOUT; |
554 long now = monotonic_now(); | 554 long now = monotonic_now(); |
555 | 555 |
556 update_timeout(KEX_REKEY_TIMEOUT, now, ses.kexstate.lastkextime, &timeout); | 556 if (!ses.kexstate.sentkexinit) { |
557 update_timeout(KEX_REKEY_TIMEOUT, now, ses.kexstate.lastkextime, &timeout); | |
558 } | |
557 | 559 |
558 if (ses.authstate.authdone != 1 && IS_DROPBEAR_SERVER) { | 560 if (ses.authstate.authdone != 1 && IS_DROPBEAR_SERVER) { |
559 /* AUTH_TIMEOUT is only relevant before authdone */ | 561 /* AUTH_TIMEOUT is only relevant before authdone */ |
560 update_timeout(AUTH_TIMEOUT, now, ses.connect_time, &timeout); | 562 update_timeout(AUTH_TIMEOUT, now, ses.connect_time, &timeout); |
561 } | 563 } |