aboutsummaryrefslogtreecommitdiffstats
path: root/src/eapol_supp
diff options
context:
space:
mode:
authorJouni Malinen <jouni@codeaurora.org>2019-03-13 21:25:21 (GMT)
committerJouni Malinen <j@w1.fi>2019-03-13 21:33:41 (GMT)
commit673631b8a3895128568eb30bdbd74d61a6a8f51b (patch)
tree87a337520d16e72f2bcd0bfabe1a7165b026b04b /src/eapol_supp
parent64766a77835ced5063e6ea512ae0f54cf041cd56 (diff)
downloadhostap-673631b8a3895128568eb30bdbd74d61a6a8f51b.zip
hostap-673631b8a3895128568eb30bdbd74d61a6a8f51b.tar.gz
hostap-673631b8a3895128568eb30bdbd74d61a6a8f51b.tar.bz2
More robust timer_tick_enabled tracking
Do not set sm->timer_tick_enabled if the eloop_register_timeout() call fails so that the next attempt to enable the timer in eapol_enable_timer_tick() can try to recover from unexpected eloop failures. This should not really be needed in practical use cases, but certain out-of-memory test cases can trigger allocation failure in eloop_register_timeout() and if that happens, the previous EAPOL supplicant state machine implementation got pretty much completely stuck for any operation needing the timer. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Diffstat (limited to 'src/eapol_supp')
-rw-r--r--src/eapol_supp/eapol_supp_sm.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/eapol_supp/eapol_supp_sm.c b/src/eapol_supp/eapol_supp_sm.c
index 9f029b0..a0f27fd 100644
--- a/src/eapol_supp/eapol_supp_sm.c
+++ b/src/eapol_supp/eapol_supp_sm.c
@@ -189,8 +189,9 @@ static void eapol_port_timers_tick(void *eloop_ctx, void *timeout_ctx)
}
if (sm->authWhile | sm->heldWhile | sm->startWhen | sm->idleWhile) {
- eloop_register_timeout(1, 0, eapol_port_timers_tick, eloop_ctx,
- sm);
+ if (eloop_register_timeout(1, 0, eapol_port_timers_tick,
+ eloop_ctx, sm) < 0)
+ sm->timer_tick_enabled = 0;
} else {
wpa_printf(MSG_DEBUG, "EAPOL: disable timer tick");
sm->timer_tick_enabled = 0;
@@ -204,9 +205,9 @@ static void eapol_enable_timer_tick(struct eapol_sm *sm)
if (sm->timer_tick_enabled)
return;
wpa_printf(MSG_DEBUG, "EAPOL: enable timer tick");
- sm->timer_tick_enabled = 1;
eloop_cancel_timeout(eapol_port_timers_tick, NULL, sm);
- eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm);
+ if (eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm) == 0)
+ sm->timer_tick_enabled = 1;
}
@@ -2141,8 +2142,8 @@ struct eapol_sm *eapol_sm_init(struct eapol_ctx *ctx)
sm->initialize = FALSE;
eapol_sm_step(sm);
- sm->timer_tick_enabled = 1;
- eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm);
+ if (eloop_register_timeout(1, 0, eapol_port_timers_tick, NULL, sm) == 0)
+ sm->timer_tick_enabled = 1;
return sm;
}