P2P: Add error message for invalid PIN
Reject invalid PIN value in p2p_connect command. Before this, typos like "pbd" as the third parameter could have resulted in OK return value since this parameter was interpreted as the PIN. Signed-hostap: Masashi Honma <masashi.honma@gmail.com>
This commit is contained in:
parent
10ac7ddf33
commit
36ebf7a1b2
1 changed files with 9 additions and 0 deletions
|
@ -2991,6 +2991,9 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
|
|||
} else if (os_strncmp(pos, "pbc", 3) == 0) {
|
||||
wps_method = WPS_PBC;
|
||||
} else {
|
||||
char *end;
|
||||
long int val;
|
||||
|
||||
pin = pos;
|
||||
pos = os_strchr(pin, ' ');
|
||||
wps_method = WPS_PIN_KEYPAD;
|
||||
|
@ -2999,6 +3002,12 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd,
|
|||
if (os_strncmp(pos, "display", 7) == 0)
|
||||
wps_method = WPS_PIN_DISPLAY;
|
||||
}
|
||||
val = strtol(pin, &end, 10);
|
||||
if (val < 0 || (os_strlen(pin) != 4 && os_strlen(pin) != 8) ||
|
||||
*end != '\0') {
|
||||
os_memcpy(buf, "FAIL-INVALID-PIN\n", 17);
|
||||
return 17;
|
||||
}
|
||||
}
|
||||
|
||||
new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method,
|
||||
|
|
Loading…
Reference in a new issue