Avoid hostapd segfault on invalid driver association event
authorJouni Malinen <j@w1.fi>
Wed, 7 Apr 2010 07:01:49 +0000 (10:01 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 7 Apr 2010 07:01:49 +0000 (10:01 +0300)
Running hostapd and wpa_supplicant on the same interface at the same
time is not expected to work, but it should not cause hostapd to crash.
Ignore station mode association events (no addr field) to avoid this.

src/ap/drv_callbacks.c

index c05e4fa..26ef584 100644 (file)
@@ -40,6 +40,19 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
        int new_assoc, res;
        struct ieee802_11_elems elems;
 
+       if (addr == NULL) {
+               /*
+                * This could potentially happen with unexpected event from the
+                * driver wrapper. This was seen at least in one case where the
+                * driver ended up being set to station mode while hostapd was
+                * running, so better make sure we stop processing such an
+                * event here.
+                */
+               wpa_printf(MSG_DEBUG, "hostapd_notif_assoc: Skip event with "
+                          "no address");
+               return -1;
+       }
+
        hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
                       HOSTAPD_LEVEL_INFO, "associated");