Skip to contentSkip to conversation

gobex: Fix not resetting SRM setup

PATCH In review Luiz Augusto von Dentz 1 participant 3 messages Mar 20, 2014 – Mar 21, 2014 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/2 gobex: Fix not resetting SRM setup

From: Luiz Augusto von Dentz <[email protected]>

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(-)
gobex/gobex.c +2 -1
index 0d9b449..d7d325b 100644
@@ -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) {
Signature · 1 line
1.8.5.3
author maintainer
#1 lore raw

PATCH 2/2 gobex/transfer: Keep request id for GET when SRM is active

From: Luiz Augusto von Dentz <[email protected]>

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(-)
gobex/gobex-transfer.c +6 -1
index 09f56ba..8498177 100644
@@ -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);
Signature · 1 line
1.8.5.3
author maintainer
#2 lore raw
In reply to Luiz Augusto von Dentz

Hi,

Quoted 25 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

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(-)
gobex/gobex.c +2 -2
index 0d9b449..d7d325b 100644
@@ -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) {
--
Quoted 1 line

1.8.5.3

Pushed.

Signature · 1 line
Luiz Augusto von Dentz