Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH obexd 1/2] gobex: remove extra define of G_OBEX_RSP_SUCCESS
@ 2011-11-07 12:29 Luiz Augusto von Dentz
  2011-11-07 12:29 ` [PATCH obexd 2/2] gobex: add check for connection id Luiz Augusto von Dentz
  2011-11-07 12:43 ` [PATCH obexd 1/2] gobex: remove extra define of G_OBEX_RSP_SUCCESS Johan Hedberg
  0 siblings, 2 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-07 12:29 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 gobex/gobex-packet.h |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/gobex/gobex-packet.h b/gobex/gobex-packet.h
index 24c9dcc..e4cea0b 100644
--- a/gobex/gobex-packet.h
+++ b/gobex/gobex-packet.h
@@ -41,7 +41,6 @@
 /* Response codes */
 #define G_OBEX_RSP_CONTINUE			0x10
 #define G_OBEX_RSP_SUCCESS			0x20
-#define G_OBEX_RSP_SUCCESS			0x20
 #define G_OBEX_RSP_CREATED			0x21
 #define G_OBEX_RSP_ACCEPTED			0x22
 #define G_OBEX_RSP_NON_AUTHORITATIVE		0x23
-- 
1.7.6.4


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

* [PATCH obexd 2/2] gobex: add check for connection id
  2011-11-07 12:29 [PATCH obexd 1/2] gobex: remove extra define of G_OBEX_RSP_SUCCESS Luiz Augusto von Dentz
@ 2011-11-07 12:29 ` Luiz Augusto von Dentz
  2011-11-07 13:05   ` Hendrik Sattler
  2011-11-07 12:43 ` [PATCH obexd 1/2] gobex: remove extra define of G_OBEX_RSP_SUCCESS Johan Hedberg
  1 sibling, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-11-07 12:29 UTC (permalink / raw)
  To: linux-bluetooth

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

Since gobex maintain the connection id of the session it is more
convenient to check whether the incoming request connection matches
before calling the application handlers.
---
 gobex/gobex.c |   29 ++++++++++++++++++++++++++---
 1 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/gobex/gobex.c b/gobex/gobex.c
index 61edbd5..62424ff 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -681,16 +681,39 @@ static void handle_response(GObex *obex, GError *err, GObexPacket *rsp)
 		enable_tx(obex);
 }
 
+static gboolean check_connid(GObex *obex, GObexPacket *pkt)
+{
+	GObexHeader *hdr;
+	guint32 id;
+
+	if (obex->conn_id == CONNID_INVALID)
+		return TRUE;
+
+	hdr = g_obex_packet_get_header(pkt, G_OBEX_HDR_CONNECTION);
+	if (hdr == NULL)
+		return FALSE;
+
+	g_obex_header_get_uint32(hdr, &id);
+
+	return obex->conn_id == id;
+}
+
 static void handle_request(GObex *obex, GObexPacket *req)
 {
 	GSList *match;
 	guint op;
 
-	if (g_obex_packet_get_operation(req, NULL) == G_OBEX_OP_CONNECT)
-		parse_connect_data(obex, req);
-
 	op = g_obex_packet_get_operation(req, NULL);
 
+	if (op == G_OBEX_OP_CONNECT)
+		parse_connect_data(obex, req);
+	else if (check_connid(obex, req) == FALSE) {
+		g_obex_debug(G_OBEX_DEBUG_ERROR, "Connection id don't match");
+		g_obex_send_rsp(obex, G_OBEX_RSP_SERVICE_UNAVAILABLE, NULL,
+							G_OBEX_HDR_INVALID);
+		return;
+	}
+
 	match = g_slist_find_custom(obex->req_handlers, GUINT_TO_POINTER(op),
 							req_handler_cmpop);
 	if (match) {
-- 
1.7.6.4


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

* Re: [PATCH obexd 1/2] gobex: remove extra define of G_OBEX_RSP_SUCCESS
  2011-11-07 12:29 [PATCH obexd 1/2] gobex: remove extra define of G_OBEX_RSP_SUCCESS Luiz Augusto von Dentz
  2011-11-07 12:29 ` [PATCH obexd 2/2] gobex: add check for connection id Luiz Augusto von Dentz
@ 2011-11-07 12:43 ` Johan Hedberg
  1 sibling, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2011-11-07 12:43 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Mon, Nov 07, 2011, Luiz Augusto von Dentz wrote:
> ---
>  gobex/gobex-packet.h |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)

Both patches have been applied. Thanks.

Johan

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

* Re: [PATCH obexd 2/2] gobex: add check for connection id
  2011-11-07 12:29 ` [PATCH obexd 2/2] gobex: add check for connection id Luiz Augusto von Dentz
@ 2011-11-07 13:05   ` Hendrik Sattler
  2011-11-07 13:16     ` Johan Hedberg
  0 siblings, 1 reply; 5+ messages in thread
From: Hendrik Sattler @ 2011-11-07 13:05 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Am 07.11.2011 13:29, schrieb Luiz Augusto von Dentz:
> +		g_obex_debug(G_OBEX_DEBUG_ERROR, "Connection id don't match");

s/don't/does not/

HS


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

* Re: [PATCH obexd 2/2] gobex: add check for connection id
  2011-11-07 13:05   ` Hendrik Sattler
@ 2011-11-07 13:16     ` Johan Hedberg
  0 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2011-11-07 13:16 UTC (permalink / raw)
  To: Hendrik Sattler; +Cc: Luiz Augusto von Dentz, linux-bluetooth

On Mon, Nov 07, 2011, Hendrik Sattler wrote:
> Am 07.11.2011 13:29, schrieb Luiz Augusto von Dentz:
> >+		g_obex_debug(G_OBEX_DEBUG_ERROR, "Connection id don't match");
> 
> s/don't/does not/

I already fixed this before pushing.

Johan

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

end of thread, other threads:[~2011-11-07 13:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-07 12:29 [PATCH obexd 1/2] gobex: remove extra define of G_OBEX_RSP_SUCCESS Luiz Augusto von Dentz
2011-11-07 12:29 ` [PATCH obexd 2/2] gobex: add check for connection id Luiz Augusto von Dentz
2011-11-07 13:05   ` Hendrik Sattler
2011-11-07 13:16     ` Johan Hedberg
2011-11-07 12:43 ` [PATCH obexd 1/2] gobex: remove extra define of G_OBEX_RSP_SUCCESS Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox