eap: Move eap->method NULL check before first dereference

Move the eap->method NULL check to fix possible crash.
This commit is contained in:
Andrew Zaborowski 2017-05-22 10:49:49 +02:00 committed by Denis Kenzior
parent e3c6d2e169
commit 0416749710
1 changed files with 9 additions and 2 deletions

View File

@ -186,16 +186,23 @@ static void eap_handle_request(struct eap_state *eap, uint16_t id,
/* Invalid packets to be ignored */ /* Invalid packets to be ignored */
return; 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) if (id == eap->last_id)
op = eap->method->handle_retransmit; op = eap->method->handle_retransmit;
else else
op = eap->method->handle_request; op = eap->method->handle_request;
eap->last_id = id; eap->last_id = id;
type = pkt[0];
if (type >= __EAP_TYPE_MIN_METHOD) { 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 " l_warn("EAP server tried method %i while client was "
"configured for method %i", "configured for method %i",
type, eap->method->request_type); type, eap->method->request_type);