From: Shijie Zhang Date: Fri, 26 Apr 2013 09:30:01 +0000 (+0300) Subject: EAP peer: Add check before calling getSessionId method X-Git-Tag: aosp-kk-from-upstream~343 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d78d3c619093cf9ecfc5b7e0537cf7cdd3df4c98;p=thirdparty%2Fhostap.git 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 950c5630768285e460aa336c78a18162fb3e0434 where EAP methods that did not implement getSessionId resulted in NULL pointer dereference when deriving the key. Signed-off-by: Shijie Zhang --- diff --git a/src/eap_peer/eap.c b/src/eap_peer/eap.c index 4df88539b..c0d707861 100644 --- a/src/eap_peer/eap.c +++ b/src/eap_peer/eap.c @@ -406,9 +406,11 @@ SM_STATE(EAP, METHOD) sm->eapKeyData = sm->m->getKey(sm, sm->eap_method_priv, &sm->eapKeyDataLen); os_free(sm->eapSessionId); - sm->eapSessionId = sm->m->getSessionId(sm, sm->eap_method_priv, - &sm->eapSessionIdLen); - if (sm->eapSessionId) { + sm->eapSessionId = NULL; + if (sm->m->getSessionId) { + sm->eapSessionId = sm->m->getSessionId( + sm, sm->eap_method_priv, + &sm->eapSessionIdLen); wpa_hexdump(MSG_DEBUG, "EAP: Session-Id", sm->eapSessionId, sm->eapSessionIdLen); }