[PATCH] dbus: fix BSS WPS/WPA/RSN IE property getters.

Marcel Holtmann marcel
Mon Jan 4 01:57:52 PST 2010


From: Witold Sowa <witold.sowa at gmail.com>

If no IE is availeble the getter will return an empty array insead of
empty message.
---
 wpa_supplicant/dbus/dbus_new_handlers.c  |   21 ++++++++++++---------
 wpa_supplicant/examples/wpas-dbus-new.py |    4 ++--
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 5f521d4..2d2e7a3 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -2527,6 +2527,7 @@ DBusMessage * wpas_dbus_getter_bss_wpaie(DBusMessage *message,
 {
 	struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
 	const u8 *ie;
+	size_t len;
 
 	if (!res) {
 		wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_wpaie[dbus]: no "
@@ -2535,10 +2536,10 @@ DBusMessage * wpas_dbus_getter_bss_wpaie(DBusMessage *message,
 	}
 
 	ie = wpa_bss_get_vendor_ie(res, WPA_IE_VENDOR_TYPE);
-	if (!ie)
-		return NULL;
+	len = ie ? ie[1] + 2 : 0;
+
 	return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
-						      ie, ie[1] + 2);
+						      ie, len);
 }
 
 
@@ -2556,6 +2557,7 @@ DBusMessage * wpas_dbus_getter_bss_rsnie(DBusMessage *message,
 {
 	struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
 	const u8 *ie;
+	size_t len;
 
 	if (!res) {
 		wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_rsnie[dbus]: no "
@@ -2564,10 +2566,10 @@ DBusMessage * wpas_dbus_getter_bss_rsnie(DBusMessage *message,
 	}
 
 	ie = wpa_bss_get_ie(res, WLAN_EID_RSN);
-	if (!ie)
-		return NULL;
+	len = ie ? ie[1] + 2 : 0;
+
 	return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
-						      ie, ie[1] + 2);
+						      ie, len);
 }
 
 
@@ -2585,6 +2587,7 @@ DBusMessage * wpas_dbus_getter_bss_wpsie(DBusMessage *message,
 {
 	struct wpa_bss *res = wpa_bss_get_id(bss->wpa_s, bss->id);
 	const u8 *ie;
+	size_t len;
 
 	if (!res) {
 		wpa_printf(MSG_ERROR, "wpas_dbus_getter_bss_wpsie[dbus]: no "
@@ -2593,10 +2596,10 @@ DBusMessage * wpas_dbus_getter_bss_wpsie(DBusMessage *message,
 	}
 
 	ie = wpa_bss_get_vendor_ie(res, WPS_IE_VENDOR_TYPE);
-	if (!ie)
-		return NULL;
+	len = ie ? ie[1] + 2 : 0;
+
 	return wpas_dbus_simple_array_property_getter(message, DBUS_TYPE_BYTE,
-						      ie, ie[1] + 2);
+						      ie, len);
 }
 
 
diff --git a/wpa_supplicant/examples/wpas-dbus-new.py b/wpa_supplicant/examples/wpas-dbus-new.py
index 156b4fb..a313197 100755
--- a/wpa_supplicant/examples/wpas-dbus-new.py
+++ b/wpa_supplicant/examples/wpas-dbus-new.py
@@ -54,12 +54,12 @@ def showBss(bss):
 	val = net_obj.Get(WPAS_DBUS_BSS_INTERFACE, 'WPAIE',
 			  dbus_interface=dbus.PROPERTIES_IFACE)
 	wpa = "no"
-	if val != None:
+	if len(val) > 0:
 		wpa = "yes"
 	val = net_obj.Get(WPAS_DBUS_BSS_INTERFACE, 'RSNIE',
 			  dbus_interface=dbus.PROPERTIES_IFACE)
 	wpa2 = "no"
-	if val != None:
+	if len(val) > 0:
 		wpa2 = "yes"
 	freq = net_obj.Get(WPAS_DBUS_BSS_INTERFACE, 'Frequency',
 			   dbus_interface=dbus.PROPERTIES_IFACE)
-- 
1.6.5.2




More information about the Hostap mailing list