From 0416749710329e512d5ac29f237c9274af5094a1 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Mon, 22 May 2017 10:49:49 +0200 Subject: [PATCH] eap: Move eap->method NULL check before first dereference Move the eap->method NULL check to fix possible crash. --- src/eap.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/eap.c b/src/eap.c index b7c6a0af..d68ff451 100644 --- a/src/eap.c +++ b/src/eap.c @@ -186,16 +186,23 @@ static void eap_handle_request(struct eap_state *eap, uint16_t id, /* Invalid packets to be ignored */ return; + type = pkt[0]; + if (type >= __EAP_TYPE_MIN_METHOD && !eap->method) { + l_warn("EAP server tried method %i while client had no method " + "configured", type); + + goto unsupported_method; + } + if (id == eap->last_id) op = eap->method->handle_retransmit; else op = eap->method->handle_request; eap->last_id = id; - type = pkt[0]; if (type >= __EAP_TYPE_MIN_METHOD) { - if (!eap->method || type != eap->method->request_type) { + if (type != eap->method->request_type) { l_warn("EAP server tried method %i while client was " "configured for method %i", type, eap->method->request_type);