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

Dan Williams dcbw
Sun Jan 30 07:41:38 PST 2011


On Tue, 2011-01-04 at 17:05 +0200, Tomasz Bursztyka wrote:
> Hello,
> 
> 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\"",
>                            entry.str_value);
>                  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]

I think it was initially intended for the PSK to be sent as a byte array
if it wasn't a passphrase.  Which implies the client does the
hex->binary conversion itself.  Which is already handled correctly.
However, if the value *is* sent as an unquoted string, then yeah, the
supplicant probably should try to make life easier by auto-converting
it.

Dan

> 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.
> 
> Tomasz
> _______________________________________________
> HostAP mailing list
> HostAP at lists.shmoo.com
> http://lists.shmoo.com/mailman/listinfo/hostap





More information about the Hostap mailing list