From: Skywing Date: Sun, 9 Nov 2008 04:07:36 +0000 (-0500) Subject: Prevent continuing of an already finished FSM. X-Git-Tag: silc.toolkit.1.1.9~17^2~2^2 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=dbc1bd097dd0090e4d0891bcd86f36e837405fda Prevent continuing of an already finished FSM. Another fix for another crash relating to misuse of FSM and callback logic in the SKE library. --- diff --git a/lib/silcske/silcske.c b/lib/silcske/silcske.c index 9cb98f71..1987ffc2 100644 --- a/lib/silcske/silcske.c +++ b/lib/silcske/silcske.c @@ -968,6 +968,7 @@ static void silc_ske_finished(SilcFSM fsm, void *fsm_context, void *destructor_context) { SilcSKE ske = fsm_context; + ske->fsm_finished = TRUE; silc_ske_free(ske); } @@ -1046,7 +1047,10 @@ void silc_ske_free(SilcSKE ske) silc_ske_notify_failure(ske); - silc_fsm_continue_sync(&ske->fsm); + if (!ske->fsm_finished) + silc_fsm_continue_sync(&ske->fsm); + else + SILC_LOG_DEBUG(("Not continuing FSM as it's finished for SKE %p", ske)); } ske->refcnt--; diff --git a/lib/silcske/silcske_i.h b/lib/silcske/silcske_i.h index 4473284b..572b0837 100644 --- a/lib/silcske/silcske_i.h +++ b/lib/silcske/silcske_i.h @@ -94,6 +94,7 @@ struct SilcSKEStruct { unsigned int responder : 1; /* Set when we are responder side */ unsigned int rekeying : 1; /* Set when rekeying */ unsigned int failure_notified : 1; /* Set to indicate that we already called the failure notify routine */ + unsigned int fsm_finished : 1; /* Set when we're in FSM teardown */ }; #endif /* SILCSKE_I_H */