---
 src/service.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/src/service.c b/src/service.c
index 5d6f384..89a12f2 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4022,6 +4022,7 @@ static void request_input_cb (struct connman_service 
*service,
                        void *user_data)
 {
        struct connman_device *device;
+       gsize length;

        DBG ("RequestInput return, %p", service);

@@ -4042,9 +4043,34 @@ static void request_input_cb (struct connman_service 
*service,
        if (identity != NULL)
                __connman_service_set_agent_identity(service, identity);

-       if (passphrase != NULL)
-               __connman_service_add_passphrase(service, passphrase);
+       if (passphrase != NULL) {
+               length = strlen(passphrase);
+               if (service->security == CONNMAN_SERVICE_SECURITY_PSK) {
+                       if (length > 8 && length < 63)
+                               __connman_service_add_passphrase(service,
+                                                               passphrase);
+                       else {
+                               __connman_service_indicate_error(service,
+                                       CONNMAN_SERVICE_ERROR_INVALID_KEY);
+                               __connman_agent_report_error(service,
+                                            error2string(service->error),
+                                            report_error_cb, NULL);
+                       }
+               } else if (service->security == CONNMAN_SERVICE_SECURITY_WEP) {
+                       if (length == 10 || length == 26 || length == 5 ||
+                                                               length == 13)
+                               __connman_service_add_passphrase(service,
+                                                               passphrase);
+                       else {
+                               __connman_service_indicate_error(service,
+                                       CONNMAN_SERVICE_ERROR_INVALID_KEY);
+                               __connman_agent_report_error(service,
+                                            error2string(service->error),
+                                            report_error_cb, NULL);
+                       }
+               }

+       }
        __connman_service_connect(service);

        /* Never cache agent provided credentials */
--
1.7.5.4

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to