From dbc1bd097dd0090e4d0891bcd86f36e837405fda Mon Sep 17 00:00:00 2001 From: Skywing Date: Sat, 8 Nov 2008 23:07:36 -0500 Subject: [PATCH] Prevent continuing of an already finished FSM. Another fix for another crash relating to misuse of FSM and callback logic in the SKE library. --- lib/silcske/silcske.c | 6 +++++- lib/silcske/silcske_i.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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 */ -- 2.24.0