diff mbox

p2p: Fix the setter function for DBus group properties

Message ID 1328316362-5956-2-git-send-email-angie.v.chinchilla@intel.com
State Accepted
Commit 4bb70bd80d61a451b598102bd26f5348846fdef0
Headers show

Commit Message

Chinchilla, Angie V Feb. 4, 2012, 12:46 a.m. UTC
From: Todd Previte <toddx.a.previte@intel.com>

The setter function uses the same hostapd_data structure as the getter which
causes it to crash if called on a P2P client. To overcome this issue, the
role is checked to ensure it is called on a group owner and the pointer
is examined for validity. The function will return an error if called on
a non-GO system.

Signed-hostap: Todd Previte <toddx.a.previte@intel.com>
Signed-hostap: Angie Chinchilla <angie.v.chinchilla@intel.com>
---
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

Comments

Chinchilla, Angie V Feb. 4, 2012, 1:08 a.m. UTC | #1
> -----Original Message-----
> From: hostap-bounces@lists.shmoo.com [mailto:hostap-
> bounces@lists.shmoo.com] On Behalf Of Angie Chinchilla
> Sent: Friday, February 03, 2012 4:46 PM
> To: hostap@lists.shmoo.com
> Cc: Previte, ToddX A
> Subject: [PATCH] p2p: Fix the setter function for DBus group properties
> 
> From: Todd Previte <toddx.a.previte@intel.com>
> 
> The setter function uses the same hostapd_data structure as the getter
> which
> causes it to crash if called on a P2P client. To overcome this issue,
> the
> role is checked to ensure it is called on a group owner and the pointer
> is examined for validity. The function will return an error if called
> on
> a non-GO system.
> 
> Signed-hostap: Todd Previte <toddx.a.previte@intel.com>
> Signed-hostap: Angie Chinchilla <angie.v.chinchilla@intel.com>
> ---
>  wpa_supplicant/dbus/dbus_new_handlers_p2p.c |   10 +++++-----
>  1 files changed, 5 insertions(+), 5 deletions(-)

intended-for: hostap-1
Jouni Malinen Feb. 4, 2012, 11:15 a.m. UTC | #2
On Fri, Feb 03, 2012 at 04:46:02PM -0800, Angie Chinchilla wrote:
> From: Todd Previte <toddx.a.previte@intel.com>
> The setter function uses the same hostapd_data structure as the getter which
> causes it to crash if called on a P2P client. To overcome this issue, the
> role is checked to ensure it is called on a group owner and the pointer
> is examined for validity. The function will return an error if called on
> a non-GO system.

Thanks! Applied.
diff mbox

Patch

diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index d621fb2..295b68e 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -1764,13 +1764,13 @@  dbus_bool_t wpas_dbus_setter_p2p_group_properties(DBusMessageIter *iter,
 	DBusMessageIter variant_iter, iter_dict;
 	struct wpa_dbus_dict_entry entry = { .type = DBUS_TYPE_STRING };
 	unsigned int i;
-	struct hostapd_data *hapd = wpa_s->ap_iface->bss[0];
+	struct hostapd_data *hapd = NULL;
 
-	if (!hapd) {
-		dbus_set_error_const(error, DBUS_ERROR_FAILED,
-				     "internal error");
+	if (wpas_get_p2p_role(wpa_s) == WPAS_P2P_ROLE_GO &&
+	    wpa_s->ap_iface != NULL)
+		hapd = wpa_s->ap_iface->bss[0];
+	else
 		return FALSE;
-	}
 
 	dbus_message_iter_recurse(iter, &variant_iter);
 	if (!wpa_dbus_dict_open_read(&variant_iter, &iter_dict, error))