linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikel Astiz <mikel.astiz.oss@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Mikel Astiz <mikel.astiz@bmw-carit.de>
Subject: [PATCH obexd v0 1/6] client: Fix possible double free of params
Date: Fri,  4 May 2012 14:39:33 +0200	[thread overview]
Message-ID: <1336135178-21707-2-git-send-email-mikel.astiz.oss@gmail.com> (raw)
In-Reply-To: <1336135178-21707-1-git-send-email-mikel.astiz.oss@gmail.com>

From: Mikel Astiz <mikel.astiz@bmw-carit.de>

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


  reply	other threads:[~2012-05-04 12:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-04 12:39 [PATCH obexd v0 0/6] Create transfers in modules Mikel Astiz
2012-05-04 12:39 ` Mikel Astiz [this message]
2012-05-04 12:39 ` [PATCH obexd v0 2/6] client: Split internal obc_transfer_register() Mikel Astiz
2012-05-04 12:39 ` [PATCH obexd v0 3/6] client: Transfer API splits create and register Mikel Astiz
2012-05-04 12:39 ` [PATCH obexd v0 4/6] client: Buffer-passing changes in transfer API Mikel Astiz
2012-05-04 12:39 ` [PATCH obexd v0 5/6] client: Flip parameter order " Mikel Astiz
2012-05-04 12:39 ` [PATCH obexd v0 6/6] client: Create transfers in modules Mikel Astiz
2012-05-15  7:44 ` [PATCH obexd v0 0/6] " Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336135178-21707-2-git-send-email-mikel.astiz.oss@gmail.com \
    --to=mikel.astiz.oss@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mikel.astiz@bmw-carit.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).