[PATCH obexd v0 1/6] client: Fix possible double free of params

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx>

obc_transfer_get() and obc_transfer_put() should only assume ownership
of the given params only in case of success. Otherwise some erros might
result in a double free of such memory.
---
 client/transfer.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/client/transfer.c b/client/transfer.c
index 411a7c0..58baa85 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -229,7 +229,6 @@ static struct obc_transfer *obc_transfer_register(DBusConnection *conn,
 						const char *filename,
 						const char *name,
 						const char *type,
-						struct obc_transfer_params *params,
 						GError **err)
 {
 	struct obc_transfer *transfer;
@@ -240,7 +239,6 @@ static struct obc_transfer *obc_transfer_register(DBusConnection *conn,
 	transfer->filename = g_strdup(filename);
 	transfer->name = g_strdup(name);
 	transfer->type = g_strdup(type);
-	transfer->params = params;
 
 	/* for OBEX specific mime types we don't need to register a transfer */
 	if (type != NULL &&
@@ -319,7 +317,7 @@ struct obc_transfer *obc_transfer_get(DBusConnection *conn,
 	int perr;
 
 	transfer = obc_transfer_register(conn, agent, G_OBEX_OP_GET, filename,
-						name, type, params, err);
+							name, type, err);
 	if (transfer == NULL)
 		return NULL;
 
@@ -329,6 +327,8 @@ struct obc_transfer *obc_transfer_get(DBusConnection *conn,
 		return NULL;
 	}
 
+	transfer->params = params;
+
 	return transfer;
 }
 
@@ -347,7 +347,7 @@ struct obc_transfer *obc_transfer_put(DBusConnection *conn,
 	int perr;
 
 	transfer = obc_transfer_register(conn, agent, G_OBEX_OP_PUT, filename,
-						name, type, params, err);
+							name, type, err);
 	if (transfer == NULL)
 		return NULL;
 
@@ -381,6 +381,7 @@ struct obc_transfer *obc_transfer_put(DBusConnection *conn,
 	}
 
 	transfer->size = st.st_size;
+	transfer->params = params;
 
 	return transfer;
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux