Hi,
I agree, you are right. I'll send a second version of the patch
following your suggestions.
Best regards,
Jose Blanquicet
On Fri, Apr 15, 2016 at 8:28 AM, Patrik Flykt
<Patrik.Flykt(a)linux.intel.com> wrote:
On Thu, 2016-04-14 at 11:18 +0200, Jose Blanquicet wrote:
> Although the gsupplicant component allows to use a raw key when a new
> network is being created through the function add_network_security_psk,
> the technology component does not allow it because in order to set the
> property TetheringPassphrase the string's length must be within the
> range [8, 63], otherwise it will be taken as wrong value without check
> if it is a raw key.
>
> ---
> src/technology.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/src/technology.c b/src/technology.c
> index 1891d06..ffc34ca 100644
> --- a/src/technology.c
> +++ b/src/technology.c
> @@ -917,13 +917,21 @@ static DBusMessage *set_property(DBusConnection *conn,
> }
> } else if (g_str_equal(name, "TetheringPassphrase")) {
> const char *str;
> + int i;
> + size_t len;
>
> dbus_message_iter_get_basic(&value, &str);
> + len = strlen(str);
>
> if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
> return __connman_error_not_supported(msg);
>
> - if (strlen(str) < 8 || strlen(str) > 63)
> + if (len == 64) {
> + for (i = 0; i < 64; i++)
> + if (!g_ascii_isxdigit(str[i]))
> + return
__connman_error_passphrase_required(msg);
> + }
> + else if (len < 8 || len > 63)
> return __connman_error_passphrase_required(msg);
>
> if (g_strcmp0(technology->tethering_passphrase, str) != 0) {
WiFi passphrase/password checking already exists in
service.c, check_passphrase(). If that function were exported in
src/connman.h for example as __connman_service_check_passphrase(), the
password check can be done centrally in one
place. CONNMAN_SERVICE_SECURITY_PSK is the only WiFi security type
currently used for tethering.
Cheers,
Patrik