From 81eb5014f6b094562ae4245921e4ea18f7a5c6a7 Mon Sep 17 00:00:00 2001 From: Jose Blanquicet Date: Wed, 13 Jul 2016 11:19:37 +0200 Subject: gsupplicant: Avoid skipping wpa_supplicant interfaces If the wpa_supplicant has been launched before ConnMan, when the Connman calls the GetAll method on fi.w1.wpa_supplicant1, the properties are returned as an array where there is an entry named "Interfaces". This entry is an array itself with only the object path of the current available interfaces. The problem occurs when ConnMan goes across this array using the function interface_added(), because this function tries also to extract the interface properties next to object path which is wrong because properties are not appended in this message reply. So, by doing dbus_message_iter_next(iter), we are actually skipping one interface of the list and it will result in a future error because the skipped interface(s) were not stored and ConnMan will not be aware of them. This issue is due to the function interface_added() is also used when signal "fi.w1.wpa_supplicant1.InterfaceAdded" arrives, and in this message the properties are actually appended. This patch aims to solve this issue by distinguishing the caller to avoid trying to extract properties if they are not appended in the message. --- gsupplicant/supplicant.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c index 09a3ac5c..4cb533d2 100644 --- a/gsupplicant/supplicant.c +++ b/gsupplicant/supplicant.c @@ -2320,6 +2320,7 @@ static void interface_added(DBusMessageIter *iter, void *user_data) { GSupplicantInterface *interface; const char *path = NULL; + bool properties_appended = GPOINTER_TO_UINT(user_data); SUPPLICANT_DBG(""); @@ -2338,18 +2339,20 @@ static void interface_added(DBusMessageIter *iter, void *user_data) if (!interface) return; + if (!properties_appended) { + supplicant_dbus_property_get_all(path, + SUPPLICANT_INTERFACE ".Interface", + interface_property, interface, + interface); + return; + } + dbus_message_iter_next(iter); if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INVALID) { supplicant_dbus_property_foreach(iter, interface_property, interface); interface_property(NULL, NULL, interface); - return; } - - supplicant_dbus_property_get_all(path, - SUPPLICANT_INTERFACE ".Interface", - interface_property, interface, - interface); } static void interface_removed(DBusMessageIter *iter, void *user_data) @@ -2479,7 +2482,7 @@ static void signal_interface_added(const char *path, DBusMessageIter *iter) SUPPLICANT_DBG("path %s %s", path, SUPPLICANT_PATH); if (g_strcmp0(path, SUPPLICANT_PATH) == 0) - interface_added(iter, NULL); + interface_added(iter, GUINT_TO_POINTER(true)); } static void signal_interface_removed(const char *path, DBusMessageIter *iter) -- cgit v1.2.1