]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Check hostapd current_mode before dereferencing it in additional places
authorAshok Kumar Ponnaiah <aponnaia@qti.qualcomm.com>
Mon, 30 Oct 2017 21:17:05 +0000 (23:17 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 30 Oct 2017 21:20:25 +0000 (23:20 +0200)
While most places using this should be for cases where the hw_features
functionality is required, there seem to be some paths that are getting
exposed in new OWE related operations where that might not be the case.
Add explicit NULL pointer checks to avoid dereferencing the pointer if
it is not set when operating with driver wrappers that do not provide
sufficient information.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/ieee802_11.c
src/ap/sta_info.c

index 65c4d88570b77ed7a43517ce0294c13f11e69d82..1aeff8798ffe920ec7339e72f31cc99740013c38 100644 (file)
@@ -3208,7 +3208,8 @@ static void handle_assoc(struct hostapd_data *hapd,
 
        sta->listen_interval = listen_interval;
 
-       if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
+       if (hapd->iface->current_mode &&
+           hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
                sta->flags |= WLAN_STA_NONERP;
        for (i = 0; i < sta->supported_rates_len; i++) {
                if ((sta->supported_rates[i] & 0x7f) > 22) {
@@ -3227,7 +3228,8 @@ static void handle_assoc(struct hostapd_data *hapd,
            !sta->no_short_slot_time_set) {
                sta->no_short_slot_time_set = 1;
                hapd->iface->num_sta_no_short_slot_time++;
-               if (hapd->iface->current_mode->mode ==
+               if (hapd->iface->current_mode &&
+                   hapd->iface->current_mode->mode ==
                    HOSTAPD_MODE_IEEE80211G &&
                    hapd->iface->num_sta_no_short_slot_time == 1)
                        ieee802_11_set_beacons(hapd->iface);
@@ -3242,7 +3244,8 @@ static void handle_assoc(struct hostapd_data *hapd,
            !sta->no_short_preamble_set) {
                sta->no_short_preamble_set = 1;
                hapd->iface->num_sta_no_short_preamble++;
-               if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
+               if (hapd->iface->current_mode &&
+                   hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
                    && hapd->iface->num_sta_no_short_preamble == 1)
                        ieee802_11_set_beacons(hapd->iface);
        }
index b1fde3cf932ff4bc0c445bcbb4f345e5a01221f8..78108cfdcd188deed77b981f43f1e54a4e4de741 100644 (file)
@@ -197,7 +197,8 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
        if (sta->no_short_slot_time_set) {
                sta->no_short_slot_time_set = 0;
                hapd->iface->num_sta_no_short_slot_time--;
-               if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
+               if (hapd->iface->current_mode &&
+                   hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
                    && hapd->iface->num_sta_no_short_slot_time == 0)
                        set_beacon++;
        }
@@ -205,7 +206,8 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
        if (sta->no_short_preamble_set) {
                sta->no_short_preamble_set = 0;
                hapd->iface->num_sta_no_short_preamble--;
-               if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
+               if (hapd->iface->current_mode &&
+                   hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
                    && hapd->iface->num_sta_no_short_preamble == 0)
                        set_beacon++;
        }