From 4e421cfc8f980b70885077cee06b40f1e2ed53fa Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 24 Mar 2017 11:44:26 -0500 Subject: [PATCH] netdev: Add sanity checks In the case we get a connect or authenticate event, make sure we're actually trying to connect. Otherwise, it could be another supplicant is running --- src/netdev.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 50f22307..49c92eec 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -1277,12 +1277,14 @@ static void netdev_connect_event(struct l_genl_msg *msg, const uint8_t *rsne = NULL; const uint8_t *mde = NULL; const uint8_t *fte = NULL; - bool is_rsn = netdev->handshake->own_ie != NULL; l_debug(""); - if (!netdev->connected) + if (!netdev->connected) { + l_warn("Unexpected connection related event -- " + "is another supplicant running?"); return; + } if (!l_genl_attr_init(&attr, msg)) { l_debug("attr init failed"); @@ -1355,6 +1357,8 @@ static void netdev_connect_event(struct l_genl_msg *msg, } if (netdev->in_ft) { + bool is_rsn = netdev->handshake->own_ie != NULL; + netdev->in_ft = false; netdev->operational = true; @@ -1566,10 +1570,16 @@ static void netdev_authenticate_event(struct l_genl_msg *msg, const uint8_t *mde = NULL; const uint8_t *fte = NULL; struct handshake_state *hs = netdev->handshake; - bool is_rsn = hs->own_ie != NULL; + bool is_rsn; l_debug(""); + if (!netdev->connected) { + l_warn("Unexpected connection related event -- " + "is another supplicant running?"); + return; + } + /* * During Fast Transition we use the authenticate event to start the * reassociation step because the FTE necessary before we can build @@ -1650,6 +1660,8 @@ static void netdev_authenticate_event(struct l_genl_msg *msg, } } + is_rsn = hs->own_ie != NULL; + /* * In an RSN, check for an RSNE containing the PMK-R0-Name and * the remaining fields same as in the advertised RSNE.