mschapv2: Call set_key_material last in handle_success

Make sure that eap_set_key_material can free the whole EAP method and
EAP state machine before returning, by calling that function last.  This
relies on eap_mschapv2_handle_success being the last call in about 5
stack frames above it too.
This commit is contained in:
Andrew Zaborowski 2017-01-06 02:51:17 -05:00 committed by Denis Kenzior
parent 15f4ddfaa6
commit c5906d1c20
1 changed files with 3 additions and 2 deletions

View File

@ -559,12 +559,13 @@ static void eap_mschapv2_handle_success(struct eap_state *eap,
goto err;
eap_method_success(eap);
/* The eapol set_key_material only needs msk, and that's all we got */
eap_set_key_material(eap, session_key, 32, NULL, 0, NULL, 0);
buffer[5] = MSCHAPV2_OP_SUCCESS;
eap_send_response(eap, EAP_TYPE_MSCHAPV2, buffer, sizeof(buffer));
/* The eapol set_key_material only needs msk, and that's all we got */
eap_set_key_material(eap, session_key, 32, NULL, 0, NULL, 0);
return;
err: