]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
EAP peer: Add check before calling getSessionId method
authorShijie Zhang <shijiez@qca.qualcomm.com>
Fri, 26 Apr 2013 09:30:01 +0000 (12:30 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 26 Apr 2013 09:30:01 +0000 (12:30 +0300)
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 <shijiez@qca.qualcomm.com>
src/eap_peer/eap.c

index 4df88539b00b4316c98d0a47bafd5b177279e7b0..c0d707861f68b2b1b64d63a985c999e8980c3e1e 100644 (file)
@@ -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);
                }