From d78d3c619093cf9ecfc5b7e0537cf7cdd3df4c98 Mon Sep 17 00:00:00 2001 From: Shijie Zhang Date: Fri, 26 Apr 2013 12:30:01 +0300 Subject: [PATCH] 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 --- src/eap_peer/eap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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); }