From fdb28673f4a3cbe4fc13ef00ba2ce81ec75c4d32 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 21 Dec 2012 23:16:33 +0200 Subject: [PATCH] obexd: Fix crash while attempting to authorize transfer Transfer need to be registered before it is authorized because AuthorizePush takes the transfer path and the agent may try to access the transfer properties to figure out its details. --- obexd/src/manager.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/obexd/src/manager.c b/obexd/src/manager.c index e53c13320..c0887ca9d 100644 --- a/obexd/src/manager.c +++ b/obexd/src/manager.c @@ -572,20 +572,10 @@ void manager_emit_transfer_started(struct obex_transfer *transfer) { static unsigned int id = 0; - transfer->path = g_strdup_printf("%s/session%u/transfer%u", - OBEX_BASE_PATH, transfer->session->id, - id++); - transfer->status = TRANSFER_STATUS_ACTIVE; - if (!g_dbus_register_interface(connection, transfer->path, - TRANSFER_INTERFACE, - transfer_methods, NULL, - transfer_properties, transfer, NULL)) { - error("Cannot register Transfer interface."); - g_free(transfer->path); - transfer->path = NULL; - } + g_dbus_emit_property_changed(connection, transfer->path, + TRANSFER_INTERFACE, "Status"); } static void emit_transfer_completed(struct obex_transfer *transfer, @@ -623,8 +613,19 @@ struct obex_transfer *manager_register_transfer(struct obex_session *os) static unsigned int id = 0; transfer = g_new0(struct obex_transfer, 1); + transfer->path = g_strdup_printf("%s/session%u/transfer%u", + OBEX_BASE_PATH, os->id, id++); transfer->session = os; + if (!g_dbus_register_interface(connection, transfer->path, + TRANSFER_INTERFACE, + transfer_methods, NULL, + transfer_properties, transfer, NULL)) { + error("Cannot register Transfer interface."); + transfer_free(transfer); + return NULL; + } + return transfer; } -- 2.47.3