D-Bus: Fix P2P Group PSK property getter
authorJouni Malinen <j@w1.fi>
Fri, 2 Jan 2015 10:20:44 +0000 (12:20 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 2 Jan 2015 20:50:27 +0000 (22:50 +0200)
This was returning a byte array of the pointer to the PSK, not the
actual PSK, due to incorrect use of
wpas_dbus_simple_array_property_getter(). In addition, there is no need
to limit this property based on the role of the device in the group, so
return the PSK if it is available (which it will be for both GO and P2P
Client roles).

Signed-off-by: Jouni Malinen <j@w1.fi>
wpa_supplicant/dbus/dbus_new_handlers_p2p.c

index a526b91..339ebdf 100644 (file)
@@ -2066,20 +2066,20 @@ dbus_bool_t wpas_dbus_getter_p2p_group_psk(DBusMessageIter *iter,
                                           DBusError *error, void *user_data)
 {
        struct wpa_supplicant *wpa_s = user_data;
-       u8 role = wpas_get_p2p_role(wpa_s);
        u8 *p_psk = NULL;
        u8 psk_len = 0;
+       struct wpa_ssid *ssid = wpa_s->current_ssid;
 
-       /* Verify correct role for this property */
-       if (role == WPAS_P2P_ROLE_CLIENT) {
-               if (wpa_s->current_ssid == NULL)
-                       return FALSE;
-               p_psk = wpa_s->current_ssid->psk;
-               psk_len = 32;
+       if (ssid == NULL)
+               return FALSE;
+
+       if (ssid->psk_set) {
+               p_psk = ssid->psk;
+               psk_len = sizeof(ssid->psk);
        }
 
        return wpas_dbus_simple_array_property_getter(iter, DBUS_TYPE_BYTE,
-                                                     &p_psk, psk_len, error);
+                                                     p_psk, psk_len, error);
 }