EAP peer: Add check before calling getSessionId method

We should not call getSessionID method if it's not provided. This fixes
a regression from commit 950c563076 where
EAP methods that did not implement getSessionId resulted in NULL pointer
dereference when deriving the key.

Signed-off-by: Shijie Zhang <shijiez@qca.qualcomm.com>
This commit is contained in:
Shijie Zhang 2013-04-26 12:30:01 +03:00 committed by Jouni Malinen
parent dd57970477
commit d78d3c6190

View file

@ -406,9 +406,11 @@ SM_STATE(EAP, METHOD)
sm->eapKeyData = sm->m->getKey(sm, sm->eap_method_priv, sm->eapKeyData = sm->m->getKey(sm, sm->eap_method_priv,
&sm->eapKeyDataLen); &sm->eapKeyDataLen);
os_free(sm->eapSessionId); os_free(sm->eapSessionId);
sm->eapSessionId = sm->m->getSessionId(sm, sm->eap_method_priv, sm->eapSessionId = NULL;
if (sm->m->getSessionId) {
sm->eapSessionId = sm->m->getSessionId(
sm, sm->eap_method_priv,
&sm->eapSessionIdLen); &sm->eapSessionIdLen);
if (sm->eapSessionId) {
wpa_hexdump(MSG_DEBUG, "EAP: Session-Id", wpa_hexdump(MSG_DEBUG, "EAP: Session-Id",
sm->eapSessionId, sm->eapSessionIdLen); sm->eapSessionId, sm->eapSessionIdLen);
} }