]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Handle Wi-Fi Display commands more carefully if P2P is disabled
authorJouni Malinen <j@w1.fi>
Thu, 6 Feb 2014 14:03:42 +0000 (16:03 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 6 Feb 2014 14:03:42 +0000 (16:03 +0200)
If P2P was disabled (e.g., due to driver not supporting it or through
p2p_disabled=1 configuration), setting Wi-Fi Display parameters could
result in segmentation fault when the WFD IE is updated without the P2P
module being initialized. Fix this by skipping the update if P2P module
is not in use. In addition, show Wi-Fi Display as disabled in "GET
wifi_display" and refuse to enable it with "SET wifi_display 1" if P2P
is not enabled.

Signed-hostap: Jouni Malinen <j@w1.fi>

wpa_supplicant/ctrl_iface.c
wpa_supplicant/wifi_display.c

index 9a3cbeaef8554d564f12c939ea08ba5435aacf25..3deb05f32548cdf66120c17373f01ddbecb78fe5 100644 (file)
@@ -440,7 +440,11 @@ static int wpa_supplicant_ctrl_iface_set(struct wpa_supplicant *wpa_s,
                ret = wpa_drv_set_p2p_powersave(wpa_s, atoi(value), -1, -1);
 #ifdef CONFIG_WIFI_DISPLAY
        } else if (os_strcasecmp(cmd, "wifi_display") == 0) {
-               wifi_display_enable(wpa_s->global, !!atoi(value));
+               int enabled = !!atoi(value);
+               if (enabled && !wpa_s->global->p2p)
+                       ret = -1;
+               else
+                       wifi_display_enable(wpa_s->global, enabled);
 #endif /* CONFIG_WIFI_DISPLAY */
        } else if (os_strcasecmp(cmd, "bssid_filter") == 0) {
                ret = set_bssid_filter(wpa_s, value);
@@ -475,8 +479,13 @@ static int wpa_supplicant_ctrl_iface_get(struct wpa_supplicant *wpa_s,
                                          wpa_s->conf->country[1]);
 #ifdef CONFIG_WIFI_DISPLAY
        } else if (os_strcasecmp(cmd, "wifi_display") == 0) {
-               res = os_snprintf(buf, buflen, "%d",
-                                 wpa_s->global->wifi_display);
+               int enabled;
+               if (wpa_s->global->p2p == NULL ||
+                   wpa_s->global->p2p_disabled)
+                       enabled = 0;
+               else
+                       enabled = wpa_s->global->wifi_display;
+               res = os_snprintf(buf, buflen, "%d", enabled);
                if (res < 0 || (unsigned int) res >= buflen)
                        return -1;
                return res;
index 578199ebe36e1fcce7f2217f586e9a47453a6e98..8435b63a779fa213a31c0a20d2f7e37c818ab92e 100644 (file)
@@ -41,6 +41,9 @@ static int wifi_display_update_wfd_ie(struct wpa_global *global)
        struct wpabuf *ie, *buf;
        size_t len, plen;
 
+       if (global->p2p == NULL)
+               return 0;
+
        wpa_printf(MSG_DEBUG, "WFD: Update WFD IE");
 
        if (!global->wifi_display) {