service: a wps pin of length 0 is valid and leads to pbc method usage
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Tue, 24 Apr 2012 14:15:57 +0000 (17:15 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 24 Apr 2012 14:14:42 +0000 (16:14 +0200)
src/service.c

index e919b01..2219a01 100644 (file)
@@ -4361,15 +4361,22 @@ int __connman_service_add_passphrase(struct connman_service *service,
 
 static int check_wpspin(const char *wpspin)
 {
+       int length;
        guint i;
 
        if (wpspin == NULL)
                return 0;
 
+       length = strlen(wpspin);
+
+       /* If 0, it will mean user wants to use PBC method */
+       if (length == 0)
+               return 0;
+
        /* A WPS PIN is always 8 chars length,
         * its content is in digit representation.
         */
-       if (strlen(wpspin) != 8)
+       if (length != 8)
                return -ENOKEY;
 
        for (i = 0; i < 8; i++)