[BUG] Cannot pass raw key through .Interface.AddNetwork Dbus method.

Tomasz Bursztyka tomasz.bursztyka
Tue Jan 4 07:05:24 PST 2011


While using WPS DBus interface I found that .Interface.AddNetwork DBus 
method (new API) cannot handle 64 characters length psk (raw key, not 
ASCII one). I got a raw key from a wps enabled AP, when disconnecting 
and reconnecting (all through DBus API), setting the psk to the given 
raw key lead to the error:
Invalid passphrase length 64 (expected: 8..63) '<the raw key>'

This message comes from config.c/wpa_config_parse_psk() function, and it 
is due to a bug in: dbus_new_handlers.c/set_network_properties() line:276
if (should_quote_opt(entry.key)) {
                 size = os_strlen(entry.str_value);
                 if (size <= 0)
                     goto error;

                 size += 3;
                 value = os_zalloc(size);
                 if (value == NULL)
                     goto error;

                 ret = os_snprintf(value, size, "\"%s\"",
                 if (ret < 0 || (size_t) ret != (size - 1))
                     goto error;
             } else {
                 value = os_strdup(entry.str_value);
                 if (value == NULL)
                     goto error;

this code puts always quotes to the entry "psk"

I presume here we should not put quotes if only psk:
- is 64 characters length
- and its content is strictely made of [0-9a-fA-F]

Well a psk cannot be 64 characters anyway, so if given psk does not 
comply with the 2nd condition it will by default go to the error 
"Invalid passphrase length ...".

I will send a patch.


More information about the Hostap mailing list