Skip to contentSkip to conversation

client: fix ad-hoc start_open DBus method name

PATCH In review Diego Santa Cruz 2 participants 4 messages Apr 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 client: fix ad-hoc start_open DBus method name

Doing 'ad-hoc <wlan> start_open <"network name">' returned a "No matching method found" error because start_open called net.connman.iwd.AdHoc.Start instead of net.connman.iwd.AdHoc.StartOpen.

---
 client/ad-hoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
client/ad-hoc.c +1 -1
index 41d5e2aa..c90f9dd6 100644
@@ -189,7 +189,7 @@ static enum cmd_status cmd_start_open(const char *device_name,
 		return CMD_STATUS_INVALID_VALUE;
 	}
 
-	proxy_interface_method_call(adhoc_i, "Start", "s",
+	proxy_interface_method_call(adhoc_i, "StartOpen", "s",
 						check_errors_method_callback,
 						argv[0]);
 
Signature · 1 line
2.18.1
#1 lore raw

PATCH 2/3 adhoc: fix bogus Failed error and segfault on stop

The netdev_leave_adhoc() returns a negative errno on errors and zero on success, but adhoc_dbus_stop() assumed the inverse when checking for an error.

Also, the DBus message was not being referenced in adhoc->pending and then adhoc_leave_cb() segfaulted attempting to dereference it.

---
 src/adhoc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/adhoc.c +3 -1
index a8ff8c3a..328433ca 100644
@@ -576,9 +576,11 @@ static struct l_dbus_message *adhoc_dbus_stop(struct l_dbus *dbus,
 	if (!adhoc->started)
 		return l_dbus_message_new_method_return(message);
 
-	if (!netdev_leave_adhoc(adhoc->netdev, adhoc_leave_cb, adhoc))
+	if (netdev_leave_adhoc(adhoc->netdev, adhoc_leave_cb, adhoc))
 		return dbus_error_failed(message);
 
+	adhoc->pending = l_dbus_message_ref(message);
+
 	return NULL;
 }
 
Signature · 1 line
2.18.1
#2 lore raw

PATCH 3/3 adhoc: segfault when exiting iwd after adhoc stop

In reply to Diego Santa Cruz

adhoc_reset() destroys ssid and sta_states but leaves the pointers around, athough the adhoc_state structure is not always freed.

This causes a segfault when exiting iwd after a client has done adhoc start and adhoc stop on a device since adhoc_reset() is called from adhoc_sta_free although it was previously called from adhoc_leave_cb().

---
 src/adhoc.c | 2 ++
 1 file changed, 2 insertions(+)
src/adhoc.c +2 -0
index 328433ca..8c61f81e 100644
@@ -131,10 +131,12 @@ static void adhoc_reset(struct adhoc_state *adhoc)
 				dbus_error_aborted(adhoc->pending));
 
 	l_free(adhoc->ssid);
+	adhoc->ssid = NULL;
 
 	netdev_station_watch_remove(adhoc->netdev, adhoc->sta_watch_id);
 
 	l_queue_destroy(adhoc->sta_states, adhoc_sta_free);
+	adhoc->sta_states = NULL;
 
 	adhoc->started = false;
 
Signature · 1 line
2.18.1
#3 lore raw
In reply to Diego Santa Cruz

Hi Diego,

Quoted 7 lines · Diego Santa Cruz

Doing 'ad-hoc <wlan> start_open <"network name">' returned a "No matching method found" error because start_open called net.connman.iwd.AdHoc.Start instead of net.connman.iwd.AdHoc.StartOpen.

---
  client/ad-hoc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Nice catches! All applied, thanks.

Regards,
-Denis