From 30ea60130fa40c7c874e8449b4ef06fa04daaa04 Mon Sep 17 00:00:00 2001 From: Arran Cudbard-Bell Date: Fri, 20 May 2022 07:46:24 -0500 Subject: [PATCH] Don't assert on resync Close #4522 --- src/lib/eap_aka_sim/module.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib/eap_aka_sim/module.c b/src/lib/eap_aka_sim/module.c index 801afedcc32..68974cdebf5 100644 --- a/src/lib/eap_aka_sim/module.c +++ b/src/lib/eap_aka_sim/module.c @@ -206,7 +206,20 @@ static unlang_action_t mod_encode(rlm_rcode_t *p_result, module_ctx_t const *mct */ vp = fr_pair_find_by_da_idx(&request->control_pairs, attr_eap_aka_sim_hmac_extra_response, 0); if (vp) { - fr_assert(!mod_session->response_hmac_extra); + /* + * We may attempt to challenge the supplicant + * twice when performing a resynchronisation. + * + * We previously asserted that the following were NULL: + * + * mod_session->response_hmac_extra + * mod_session->ctx.k_encr + * mod_session->ctx.k_aut + * + * but that is incorrect, as these fields need to be + * updated if new vectors are available. + */ + talloc_free(mod_session->response_hmac_extra); MEM(mod_session->response_hmac_extra = talloc_memdup(mod_session, vp->vp_octets, vp->vp_length)); mod_session->response_hmac_extra_len = vp->vp_length; @@ -216,7 +229,7 @@ static unlang_action_t mod_encode(rlm_rcode_t *p_result, module_ctx_t const *mct */ vp = fr_pair_find_by_da_idx(&request->control_pairs, attr_eap_aka_sim_k_encr, 0); if (vp) { - fr_assert(!mod_session->ctx.k_encr); + talloc_free(mod_session->ctx.k_encr); MEM(mod_session->ctx.k_encr = talloc_memdup(mod_session, vp->vp_octets, vp->vp_length)); } @@ -225,7 +238,7 @@ static unlang_action_t mod_encode(rlm_rcode_t *p_result, module_ctx_t const *mct */ vp = fr_pair_find_by_da_idx(&request->control_pairs, attr_eap_aka_sim_k_aut, 0); if (vp) { - fr_assert(!mod_session->ctx.k_aut); + talloc_free(mod_session->ctx.k_aut); MEM(mod_session->ctx.k_aut = talloc_memdup(mod_session, vp->vp_octets, vp->vp_length)); mod_session->ctx.k_aut_len = vp->vp_length; } -- 2.47.3