Move p2p_connect PIN format validation into a separate function
This functionality could be shared for other commands, too, so move it to a common function. In addition, implement the validation in a bit more strict way to avoid accepting values like '-123' as a valid PIN. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
36ebf7a1b2
commit
dcc3305701
3 changed files with 18 additions and 6 deletions
|
@ -2991,9 +2991,6 @@ 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;
|
||||
|
@ -3002,9 +2999,7 @@ 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') {
|
||||
if (!wps_pin_str_valid(pin)) {
|
||||
os_memcpy(buf, "FAIL-INVALID-PIN\n", 17);
|
||||
return 17;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue