diff options
author | Jouni Malinen <j@w1.fi> | 2012-06-30 21:27:32 +0300 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2012-06-30 21:27:32 +0300 |
commit | dcc3305701495d807d9378c904d3f333c7cad837 (patch) | |
tree | b96254beb5ed1011d1d004af4b22ca24846a69a5 /src/wps/wps_common.c | |
parent | 36ebf7a1b23e1e0abe51338aead0188f86fa776c (diff) | |
download | external_wpa_supplicant_8_ti-dcc3305701495d807d9378c904d3f333c7cad837.zip external_wpa_supplicant_8_ti-dcc3305701495d807d9378c904d3f333c7cad837.tar.gz external_wpa_supplicant_8_ti-dcc3305701495d807d9378c904d3f333c7cad837.tar.bz2 |
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>
Diffstat (limited to 'src/wps/wps_common.c')
-rw-r--r-- | src/wps/wps_common.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wps/wps_common.c b/src/wps/wps_common.c index 9e06087..5a8817f 100644 --- a/src/wps/wps_common.c +++ b/src/wps/wps_common.c @@ -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) { |