From: Bartosz Szatkowski <bulislaw@linux.com>
To: linux-bluetooth@vger.kernel.org
Cc: Bartosz Szatkowski <bulislaw@linux.com>
Subject: [PATCH obexd 2/2] client: Fix invalid write in get_buf_xfer_progress
Date: Mon, 21 Nov 2011 09:32:33 +0100 [thread overview]
Message-ID: <1321864353-3159-2-git-send-email-bulislaw@linux.com> (raw)
In-Reply-To: <1321864353-3159-1-git-send-email-bulislaw@linux.com>
Segmentation fault occurred when there were no (NULL) params in
obc_session_get, but actual params were returned in response, as
corresponding structure is reused - but not created in the first place.
---
client/session.c | 2 +-
client/transfer.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/session.c b/client/session.c
index f288ecd..e51faf1 100644
--- a/client/session.c
+++ b/client/session.c
@@ -1231,8 +1231,8 @@ int obc_session_get(struct obc_session *session, const char *type,
if (session->obex == NULL)
return -ENOTCONN;
+ params = g_new0(struct obc_transfer_params, 1);
if (apparam != NULL) {
- params = g_new0(struct obc_transfer_params, 1);
params->data = g_new(guint8, apparam_size);
memcpy(params->data, apparam, apparam_size);
params->size = apparam_size;
diff --git a/client/transfer.c b/client/transfer.c
index 334d8d4..0a44af5 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -533,7 +533,7 @@ int obc_transfer_get(struct obc_transfer *transfer, transfer_callback_t func,
g_obex_packet_add_bytes(req, G_OBEX_HDR_TYPE, transfer->type,
strlen(transfer->type) + 1);
- if (transfer->params != NULL) {
+ if (transfer->params != NULL && transfer->params->size != 0) {
g_obex_packet_add_bytes(req, G_OBEX_HDR_APPARAM,
transfer->params->data,
transfer->params->size);
--
1.7.4.1
next prev parent reply other threads:[~2011-11-21 8:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-21 8:32 [PATCH obexd 1/2] client: Fix memory leak connected to params Bartosz Szatkowski
2011-11-21 8:32 ` Bartosz Szatkowski [this message]
2011-11-21 9:53 ` [PATCH obexd 2/2] client: Fix invalid write in get_buf_xfer_progress Luiz Augusto von Dentz
2011-11-21 9:50 ` [PATCH obexd 1/2] client: Fix memory leak connected to params Luiz Augusto von Dentz
-- strict thread matches above, loose matches on Subject: below --
2011-11-21 10:36 Bartosz Szatkowski
2011-11-21 10:36 ` [PATCH obexd 2/2] client: Fix invalid write in get_buf_xfer_progress Bartosz Szatkowski
2011-11-21 11:01 ` Luiz Augusto von Dentz
2011-11-21 11:32 ` Bartosz Szatkowski
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=1321864353-3159-2-git-send-email-bulislaw@linux.com \
--to=bulislaw@linux.com \
--cc=linux-bluetooth@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.