[PATCH] Dbus handlers

Dan Williams dcbw
Tue Feb 12 08:10:36 PST 2008


On Tue, 2008-02-12 at 15:09 +0100, Alban Browaeys wrote:
> The dbus handlers where broken. They tried to send the address of the ie
> internals instead of the data itself . This small patch fixes this.

Note that this issue doesn't affect the stable branch, because there the
parameters to wpa_dbus_dict_append_byte_array() are actually _arrays_,
not pointers, and therefore the & operator performs as expected.

There are two issues here:

1) The comment about D-Bus requiring the address of the variable is
wrong, because wpa_dbus_dict_append_byte_array() handles all of that for
you

2) Commit 3e4bd73d5382c5942c79df5b71aa0cd3f5b943d8 incorrectly changed
the handling of these array values to pointers, keeping the & instead of
dropping it when moving from u8[] to u8*

Following patch is simpler and removes the erroneous comment.


diff --git a/wpa_supplicant/ctrl_iface_dbus_handlers.c b/wpa_supplicant/ctrl_iface_dbus_handlers.c
index 7923d76..1735008 100644
--- a/wpa_supplicant/ctrl_iface_dbus_handlers.c
+++ b/wpa_supplicant/ctrl_iface_dbus_handlers.c
@@ -379,15 +379,8 @@ DBusMessage * wpas_dbus_bssid_properties(DBusMessage *message,
 					 struct wpa_scan_res *res)
 {
 	DBusMessage *reply = NULL;
-	char *bssid_data;
 	DBusMessageIter iter, iter_dict;
 	const u8 *ie;
-	size_t len;
-
-	/* dbus needs the address of a pointer to the actual value
-	 * for array types, not the address of the value itself.
-	 */
-	bssid_data = (char *) &res->bssid;
 
 	/* Dump the properties into a dbus message */
 	reply = dbus_message_new_method_return(message);
@@ -397,37 +390,31 @@ DBusMessage * wpas_dbus_bssid_properties(DBusMessage *message,
 		goto error;
 
 	if (!wpa_dbus_dict_append_byte_array(&iter_dict, "bssid",
-					     bssid_data, ETH_ALEN))
+					     (const char *) res->bssid,
+					     ETH_ALEN))
 		goto error;
 
 	ie = wpa_scan_get_ie(res, WLAN_EID_SSID);
 	if (ie) {
-		const char *ssid_data;
-		len = ie[1];
-		ie += 2;
-		ssid_data = (const char *) &ie;
 		if (!wpa_dbus_dict_append_byte_array(&iter_dict, "ssid",
-						     ssid_data, len))
+						     (const char *) (ie + 2),
+						     ie[1]))
 		goto error;
 	}
 
 	ie = wpa_scan_get_vendor_ie(res, WPA_IE_VENDOR_TYPE);
 	if (ie) {
-		const char *wpa_ie_data;
-		len = 2 + ie[1];
-		wpa_ie_data = (const char *) &ie;
 		if (!wpa_dbus_dict_append_byte_array(&iter_dict, "wpaie",
-						     wpa_ie_data, len))
+						     (const char *) ie,
+						     ie[1] + 2))
 			goto error;
 	}
 
 	ie = wpa_scan_get_ie(res, WLAN_EID_RSN);
 	if (ie) {
-		const char *rsn_ie_data;
-		len = 2 + ie[1];
-		rsn_ie_data = (const char *) &ie;
 		if (!wpa_dbus_dict_append_byte_array(&iter_dict, "rsnie",
-						     rsn_ie_data, len))
+						     (const char *) ie,
+						     ie[1] + 2))
 			goto error;
 	}
 




More information about the Hostap mailing list