From e10d79b53fecb7ef39613468e25741c669beeb91 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Tue, 17 Jul 2018 14:15:58 -0700 Subject: [PATCH] netdev: ensure proper iftype on connect/disconnect Now that the device mode can be changed, netdev must check that the iftype is correct before starting a connection or disconnecting. netdev_connect, netdev_connect_wsc, and netdev_disconnect now check that the iftype is station before continuing. --- src/netdev.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/netdev.c b/src/netdev.c index 1c5e4ba5..de30e728 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -2331,6 +2331,9 @@ int netdev_connect(struct netdev *netdev, struct scan_bss *bss, struct eapol_sm *sm = NULL; bool is_rsn = hs->own_ie != NULL; + if (netdev->type != NL80211_IFTYPE_STATION) + return -ENOTSUP; + if (netdev->connected) return -EISCONN; @@ -2360,6 +2363,9 @@ int netdev_connect_wsc(struct netdev *netdev, struct scan_bss *bss, size_t ie_len; struct eapol_sm *sm; + if (netdev->type != NL80211_IFTYPE_STATION) + return -ENOTSUP; + if (netdev->connected) return -EISCONN; @@ -2400,6 +2406,9 @@ int netdev_disconnect(struct netdev *netdev, { struct l_genl_msg *disconnect; + if (netdev->type != NL80211_IFTYPE_STATION) + return -ENOTSUP; + if (!netdev->connected) return -ENOTCONN;