linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] gobex: Fix not resetting SRM setup
@ 2014-03-20 17:20 Luiz Augusto von Dentz
  2014-03-20 17:20 ` [PATCH BlueZ 2/2] gobex/transfer: Keep request id for GET when SRM is active Luiz Augusto von Dentz
  2014-03-21 14:15 ` [PATCH BlueZ 1/2] gobex: Fix not resetting SRM setup Luiz Augusto von Dentz
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2014-03-20 17:20 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

If SRM is not confirmed by both ends the setup should be disregarded and
the data associated to it can be freed otherwise the next command may
reuse the same setup assuming it is still valid and probably cause SRM
to be enabled without remote consent.
---
 gobex/gobex.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gobex/gobex.c b/gobex/gobex.c
index 0d9b449..d7d325b 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -400,7 +400,8 @@ static void setup_srm(GObex *obex, GObexPacket *pkt, gboolean outgoing)
 		g_obex_header_get_uint8(hdr, &srm);
 		g_obex_debug(G_OBEX_DEBUG_COMMAND, "srm 0x%02x", srm);
 		set_srm(obex, op, srm);
-	}
+	} else if (!g_obex_srm_enabled(obex))
+		set_srm(obex, op, G_OBEX_SRM_DISABLE);
 
 	hdr = g_obex_packet_get_header(pkt, G_OBEX_HDR_SRMP);
 	if (hdr != NULL) {
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH BlueZ 2/2] gobex/transfer: Keep request id for GET when SRM is active
  2014-03-20 17:20 [PATCH BlueZ 1/2] gobex: Fix not resetting SRM setup Luiz Augusto von Dentz
@ 2014-03-20 17:20 ` Luiz Augusto von Dentz
  2014-03-21 14:15 ` [PATCH BlueZ 1/2] gobex: Fix not resetting SRM setup Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2014-03-20 17:20 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

In case a GET operation is in progress with SRM the same request id is
valid for the whole transfer otherwise it is not possible to cancel the
transfer after the first response.
---
 gobex/gobex-transfer.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gobex/gobex-transfer.c b/gobex/gobex-transfer.c
index 09f56ba..8498177 100644
--- a/gobex/gobex-transfer.c
+++ b/gobex/gobex-transfer.c
@@ -195,9 +195,11 @@ static void transfer_response(GObex *obex, GError *err, GObexPacket *rsp,
 	struct transfer *transfer = user_data;
 	GObexPacket *req;
 	gboolean rspcode, final;
+	guint id;
 
 	g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id);
 
+	id = transfer->req_id;
 	transfer->req_id = 0;
 
 	if (err != NULL) {
@@ -230,8 +232,11 @@ static void transfer_response(GObex *obex, GError *err, GObexPacket *rsp,
 	} else if (!g_obex_srm_active(transfer->obex)) {
 		req = g_obex_packet_new(transfer->opcode, TRUE,
 							G_OBEX_HDR_INVALID);
-	} else
+	} else {
+		/* Keep id since request still outstanting */
+		transfer->req_id = id;
 		return;
+	}
 
 	transfer->req_id = g_obex_send_req(obex, req, -1, transfer_response,
 							transfer, &err);
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ 1/2] gobex: Fix not resetting SRM setup
  2014-03-20 17:20 [PATCH BlueZ 1/2] gobex: Fix not resetting SRM setup Luiz Augusto von Dentz
  2014-03-20 17:20 ` [PATCH BlueZ 2/2] gobex/transfer: Keep request id for GET when SRM is active Luiz Augusto von Dentz
@ 2014-03-21 14:15 ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2014-03-21 14:15 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org

Hi,

On Thu, Mar 20, 2014 at 7:20 PM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> If SRM is not confirmed by both ends the setup should be disregarded and
> the data associated to it can be freed otherwise the next command may
> reuse the same setup assuming it is still valid and probably cause SRM
> to be enabled without remote consent.
> ---
>  gobex/gobex.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gobex/gobex.c b/gobex/gobex.c
> index 0d9b449..d7d325b 100644
> --- a/gobex/gobex.c
> +++ b/gobex/gobex.c
> @@ -400,7 +400,8 @@ static void setup_srm(GObex *obex, GObexPacket *pkt, gboolean outgoing)
>                 g_obex_header_get_uint8(hdr, &srm);
>                 g_obex_debug(G_OBEX_DEBUG_COMMAND, "srm 0x%02x", srm);
>                 set_srm(obex, op, srm);
> -       }
> +       } else if (!g_obex_srm_enabled(obex))
> +               set_srm(obex, op, G_OBEX_SRM_DISABLE);
>
>         hdr = g_obex_packet_get_header(pkt, G_OBEX_HDR_SRMP);
>         if (hdr != NULL) {
> --
> 1.8.5.3

Pushed.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-21 14:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-20 17:20 [PATCH BlueZ 1/2] gobex: Fix not resetting SRM setup Luiz Augusto von Dentz
2014-03-20 17:20 ` [PATCH BlueZ 2/2] gobex/transfer: Keep request id for GET when SRM is active Luiz Augusto von Dentz
2014-03-21 14:15 ` [PATCH BlueZ 1/2] gobex: Fix not resetting SRM setup Luiz Augusto von Dentz

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).