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
|
@ -816,6 +816,7 @@ int wps_build_credential_wrap(struct wpabuf *msg,
|
|||
unsigned int wps_pin_checksum(unsigned int pin);
|
||||
unsigned int wps_pin_valid(unsigned int pin);
|
||||
unsigned int wps_generate_pin(void);
|
||||
int wps_pin_str_valid(const char *pin);
|
||||
void wps_free_pending_msgs(struct upnp_pending_message *msgs);
|
||||
|
||||
struct oob_device_data * wps_get_oob_device(char *device_type);
|
||||
|
|
|
@ -249,6 +249,22 @@ unsigned int wps_generate_pin(void)
|
|||
}
|
||||
|
||||
|
||||
int wps_pin_str_valid(const char *pin)
|
||||
{
|
||||
const char *p;
|
||||
size_t len;
|
||||
|
||||
p = pin;
|
||||
while (*p >= '0' && *p <= '9')
|
||||
p++;
|
||||
if (*p != '\0')
|
||||
return 0;
|
||||
|
||||
len = p - pin;
|
||||
return len == 4 || len == 8;
|
||||
}
|
||||
|
||||
|
||||
void wps_fail_event(struct wps_context *wps, enum wps_msg_type msg,
|
||||
u16 config_error, u16 error_indication)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue