Hi Julien,
On 03/22/2012 11:24 AM, Julien Massot wrote:
If gsupplicant sends a passphrase shorter than 7 characters,
wpa_supplicant return an error "invalid message format",
parsing this error avoids an endless loop of connection failed.
---
gsupplicant/supplicant.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 5db1fcd..80adfdc 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2684,10 +2684,15 @@ static int parse_supplicant_error(DBusMessageIter *iter)
int err = -ECANCELED;
char *key;
+ /* If the given passphrase is under 7 characters wpa_s return
+ * "invalid message format" but this error should be interpreted as
+ * invalid-key.
+ */
while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRING) {
dbus_message_iter_get_basic(iter,&key);
- if (strncmp(key, "psk", 4) == 0 ||
- strncmp(key, "wep_key", 7) == 0) {
+ if (strncmp(key, "psk", 3) == 0 ||
+ strncmp(key, "wep_key", 7) == 0 ||
+ strncmp(key, "invalid", 7) == 0) {
err = -ENOKEY;
break;
}
Very minor style thing but in order to improve readability, could we
indent the last two strncmp() one or two places like this:
+ if (strncmp(key, "psk", 3) == 0 ||
+ strncmp(key, "wep_key", 7) == 0 ||
+ strncmp(key, "invalid", 7) == 0) {
err = -ENOKEY;
break;
}
Also what about opening the added strncmp() i.e.,
strcmp(key, "invalid message format") == 0
this way we will not match any other strings starting with "invalid".
Cheers,
Jukka
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman