OSDN Git Service

wpa_supplicant: Fix P2P command processing
authorDmitry Shmidt <dimitrysh@google.com>
Thu, 13 Sep 2012 17:39:48 +0000 (10:39 -0700)
committerDmitry Shmidt <dimitrysh@google.com>
Thu, 13 Sep 2012 17:39:48 +0000 (10:39 -0700)
Change-Id: Ib2e811513be7b05178e310040f7cae14cb425421
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/ctrl_iface_unix.c

index 480c077..0d8821b 100644 (file)
@@ -3552,12 +3552,6 @@ static int p2p_ctrl_invite_persistent(struct wpa_supplicant *wpa_s, char *cmd)
        int ht40;
 
        id = atoi(cmd);
-       pos = os_strstr(cmd, " peer=");
-       if (pos) {
-               pos += 6;
-               if (hwaddr_aton(pos, peer))
-                       return -1;
-       }
        ssid = wpa_config_get_network(wpa_s->conf, id);
        if (ssid == NULL || ssid->disabled != 2) {
                wpa_printf(MSG_DEBUG, "CTRL_IFACE: Could not find SSID id=%d "
@@ -3574,6 +3568,13 @@ static int p2p_ctrl_invite_persistent(struct wpa_supplicant *wpa_s, char *cmd)
                        return -1;
        }
 
+       pos = os_strstr(cmd, " peer=");
+       if (pos) {
+               pos += 6;
+               if (hwaddr_aton(pos, peer))
+                       return -1;
+       }
+
        ht40 = os_strstr(cmd, " ht40") != NULL;
 
        return wpas_p2p_invite(wpa_s, pos ? peer : NULL, ssid, NULL, freq,
index 5d81b43..80db27e 100644 (file)
@@ -175,7 +175,7 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
                        if (ifend != NULL)
                                *ifend++ = '\0';
                        else
-                               ifend = "";
+                               *(ifname - 1) = '\0';
                        wpa_printf(MSG_DEBUG, "Found %s", ifname);
                        for (wpa_s = wpa_s->global->ifaces; wpa_s; wpa_s = wpa_s->next) {
                                if (os_strcmp(wpa_s->ifname, ifname + 10) == 0)
@@ -185,8 +185,9 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
                                wpa_printf(MSG_ERROR, "P2P: %s does not exist", ifname);
                                wpa_s = eloop_ctx;
                        }
-                       os_memmove(ifname, ifend, strlen(ifend) + 1);
-                       wpa_printf(MSG_INFO, "wpa_s %p cmd %s", wpa_s, buf);
+                       if (ifend != NULL)
+                               os_memmove(ifname, ifend, strlen(ifend) + 1);
+                       wpa_printf(MSG_INFO, "wpa_s->ifname %s cmd %s", wpa_s ? wpa_s->ifname : "NULL", buf);
                }
 #endif /* defined CONFIG_P2P && defined ANDROID_P2P */
                reply = wpa_supplicant_ctrl_iface_process(wpa_s, buf,