aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-01-01 09:42:32 (GMT)
committerJouni Malinen <j@w1.fi>2015-01-02 20:50:26 (GMT)
commit054dc3136f798583f537e1ae11fdf096b5309fb6 (patch)
tree73b38a36b7e41e93a19b93d3dba41a985cd36663 /wpa_supplicant/dbus/dbus_new_handlers_p2p.c
parentb76ea413b16024625e93e73f123dc11291f43e9b (diff)
downloadhostap-054dc3136f798583f537e1ae11fdf096b5309fb6.zip
hostap-054dc3136f798583f537e1ae11fdf096b5309fb6.tar.gz
hostap-054dc3136f798583f537e1ae11fdf096b5309fb6.tar.bz2
D-Bus: Clean up wpas_dbus_new_decompose_object_path()
None of the new D-Bus interface cases use the bssid_part in decompose_object_path (while the old interface ones do). As such, this is dead code and can be removed. In addition, the P2P addition here was pretty ugly extension. Replace these with a cleaner way of passing the separating string (e.g., "Networks") from the caller and returning the requested item. In addition, there is no need to allocate the returned item separately, so use a single allocation and a pointer to that allocated memory. This will make it easier for callers to have to free only a single allocation. This is also fixing a memory leak in P2P invitation persistent group case where the caller had missed the need to free the returned values. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/dbus/dbus_new_handlers_p2p.c')
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_p2p.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index e95ee98..e3b8505 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -308,7 +308,6 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message,
int persistent_group = 0;
int freq = 0;
char *iface = NULL;
- char *net_id_str = NULL;
unsigned int group_id = 0;
struct wpa_ssid *ssid;
@@ -342,13 +341,16 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message,
wpa_s = wpa_s->p2p_dev;
if (pg_object_path != NULL) {
+ char *net_id_str;
+
/*
* A persistent group Object Path is defined meaning we want
* to re-invoke a persistent group.
*/
- iface = wpas_dbus_new_decompose_object_path(pg_object_path, 1,
- &net_id_str, NULL);
+ iface = wpas_dbus_new_decompose_object_path(
+ pg_object_path, WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART,
+ &net_id_str);
if (iface == NULL ||
os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
reply =
@@ -381,7 +383,6 @@ DBusMessage * wpas_dbus_handler_p2p_group_add(DBusMessage *message,
out:
os_free(pg_object_path);
- os_free(net_id_str);
os_free(iface);
return reply;
inv_args_clear:
@@ -594,7 +595,6 @@ DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
char *peer_object_path = NULL;
char *pg_object_path = NULL;
char *iface = NULL;
- char *net_id_str = NULL;
u8 peer_addr[ETH_ALEN];
unsigned int group_id = 0;
int persistent = 0;
@@ -635,13 +635,16 @@ DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
wpa_s = wpa_s->p2p_dev;
if (persistent) {
+ char *net_id_str;
/*
* A group ID is defined meaning we want to re-invoke a
* persistent group
*/
- iface = wpas_dbus_new_decompose_object_path(pg_object_path, 1,
- &net_id_str, NULL);
+ iface = wpas_dbus_new_decompose_object_path(
+ pg_object_path,
+ WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART,
+ &net_id_str);
if (iface == NULL ||
os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
reply = wpas_dbus_error_invalid_args(message,
@@ -681,6 +684,7 @@ DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
}
out:
+ os_free(iface);
os_free(pg_object_path);
os_free(peer_object_path);
return reply;
@@ -1879,7 +1883,7 @@ DBusMessage * wpas_dbus_handler_remove_persistent_group(
{
DBusMessage *reply = NULL;
const char *op;
- char *iface = NULL, *persistent_group_id = NULL;
+ char *iface = NULL, *persistent_group_id;
int id;
struct wpa_ssid *ssid;
@@ -1890,9 +1894,9 @@ DBusMessage * wpas_dbus_handler_remove_persistent_group(
* Extract the network ID and ensure the network is actually a child of
* this interface.
*/
- iface = wpas_dbus_new_decompose_object_path(op, 1,
- &persistent_group_id,
- NULL);
+ iface = wpas_dbus_new_decompose_object_path(
+ op, WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART,
+ &persistent_group_id);
if (iface == NULL || os_strcmp(iface, wpa_s->dbus_new_path) != 0) {
reply = wpas_dbus_error_invalid_args(message, op);
goto out;
@@ -1925,7 +1929,6 @@ DBusMessage * wpas_dbus_handler_remove_persistent_group(
out:
os_free(iface);
- os_free(persistent_group_id);
return reply;
}