P2PS: Fix p2p_find last parameter handling

In p2p_find command line processing a loop searching for multiple
'seek=' parameters modifies cmd buffer adding '\0' terminators.
The 'freq=' parameter is handled after that and can be
lost if a 'freq=' follows 'seek=' in a command line.
Fix it by moving a handling of 'freq=' parameter to be processed
before 'seek=' handling loop.

Signed-off-by: Max Stepanov <Max.Stepanov@intel.com>
This commit is contained in:
Stepanov, Max 2015-06-23 13:52:22 +00:00 committed by Jouni Malinen
parent 6c7314917b
commit a9ea609ce8

View file

@ -4595,6 +4595,14 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
} else } else
search_delay = wpas_p2p_search_delay(wpa_s); search_delay = wpas_p2p_search_delay(wpa_s);
pos = os_strstr(cmd, "freq=");
if (pos) {
pos += 5;
freq = atoi(pos);
if (freq <= 0)
return -1;
}
/* Must be searched for last, because it adds nul termination */ /* Must be searched for last, because it adds nul termination */
pos = os_strstr(cmd, " seek="); pos = os_strstr(cmd, " seek=");
if (pos) if (pos)
@ -4617,14 +4625,6 @@ static int p2p_ctrl_find(struct wpa_supplicant *wpa_s, char *cmd)
seek_count = 1; seek_count = 1;
} }
pos = os_strstr(cmd, "freq=");
if (pos) {
pos += 5;
freq = atoi(pos);
if (freq <= 0)
return -1;
}
return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL, _dev_type, return wpas_p2p_find(wpa_s, timeout, type, _dev_type != NULL, _dev_type,
_dev_id, search_delay, seek_count, seek, freq); _dev_id, search_delay, seek_count, seek, freq);
} }