linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] Obexd / MAP-client bug fixes
@ 2013-01-11 15:55 Christian Fetzer
  2013-01-11 15:55 ` [PATCH 1/8] obexd: Handle empty path name in SetPath Christian Fetzer
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Christian Fetzer @ 2013-01-11 15:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Christian Fetzer

From: Christian Fetzer <christian.fetzer@bmw-carit.de>

This patch set fixes a couple of small issues in the MAP-client implementation
and in the generic obexd client code.

Christian Fetzer (8):
  obexd: Handle empty path name in SetPath
  obexd: Add property exist functions to map client
  obexd: Fix infinite loop in ListMessages with filter "Types"
  obexd: Fix FILTER_ALL in MAP client to set 16 bit
  obexd: Fix segfault in parse_filter_read and parse_filter_priority
  obexd: Use defines for values in parse_filter_read parse_filter_priority
  obexd: Change behavior of parse_filter_read
  obexd: Remove transferred file only if the GET operation failed

 obexd/client/map.c      | 108 +++++++++++++++++++++++++++++++++++++++++-------
 obexd/client/session.c  |   2 +-
 obexd/client/transfer.c |   3 +-
 3 files changed, 96 insertions(+), 17 deletions(-)

-- 
1.8.1


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

* [PATCH 1/8] obexd: Handle empty path name in SetPath
  2013-01-11 15:55 [PATCH 0/8] Obexd / MAP-client bug fixes Christian Fetzer
@ 2013-01-11 15:55 ` Christian Fetzer
  2013-01-13 15:55   ` Luiz Augusto von Dentz
  2013-01-11 15:55 ` [PATCH 2/8] obexd: Add property exist functions to map client Christian Fetzer
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Christian Fetzer @ 2013-01-11 15:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Christian Fetzer

From: Christian Fetzer <christian.fetzer@bmw-carit.de>

If the empty path is given, an empty name should be sent via OBEX.
Currently the name field is not set at all and later checks which
depend on data->index will access invalid memory regions as g_strsplit
returns NULL when an empty string is given.

0  0x000000000041a181 in g_obex_setpath (obex=obex@entry=0x662eb0, path=
    0x20 <Address 0x20 out of bounds>, func=func@entry=0x42d300 <setpath_cb>,
    user_data=user_data@entry=0x668f10, err=err@entry=0x7fffffffda08)
    at gobex/gobex.c:1397
1  0x000000000042d395 in setpath_cb (obex=0x662eb0, err=0x0, rsp=<optimized out>,
    user_data=0x668f10) at obexd/client/session.c:902
2  0x0000000000418e54 in handle_response (obex=obex@entry=0x662eb0, err=err@entry=0x0,
    rsp=rsp@entry=0x668f40) at gobex/gobex.c:948
3  0x0000000000419d7a in incoming_data (io=<optimized out>, cond=<optimized out>,
    user_data=0x662eb0) at gobex/gobex.c:1191
4  0x00007ffff703c845 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
5  0x00007ffff703cb78 in ?? () from /usr/lib/libglib-2.0.so.0
6  0x00007ffff703cf72 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
7  0x000000000040def2 in main (argc=1, argv=0x7fffffffdd88) at obexd/src/main.c:323
---
 obexd/client/session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/obexd/client/session.c b/obexd/client/session.c
index 9cc824e..db37a86 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
@@ -934,7 +934,7 @@ guint obc_session_setpath(struct obc_session *session, const char *path,
 	p = pending_request_new(session, NULL, setpath_complete, data);
 
 	/* Relative path */
-	if (path[0] != '/') {
+	if (path[0] != '/' && path[0] != 0) {
 		first = data->remaining[data->index];
 		data->index++;
 	}
-- 
1.8.1


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

* [PATCH 2/8] obexd: Add property exist functions to map client
  2013-01-11 15:55 [PATCH 0/8] Obexd / MAP-client bug fixes Christian Fetzer
  2013-01-11 15:55 ` [PATCH 1/8] obexd: Handle empty path name in SetPath Christian Fetzer
@ 2013-01-11 15:55 ` Christian Fetzer
  2013-01-11 15:55 ` [PATCH 3/8] obexd: Fix infinite loop in ListMessages with filter "Types" Christian Fetzer
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Christian Fetzer @ 2013-01-11 15:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Christian Fetzer

From: Christian Fetzer <christian.fetzer@bmw-carit.de>

This fixes crashes in MAP client when the server does not send optional properties.

0  0x00007ffff6a792c5 in raise () from /usr/lib/libc.so.6
1  0x00007ffff6a7a748 in abort () from /usr/lib/libc.so.6
2  0x00007ffff731c145 in ?? () from /usr/lib/libdbus-1.so.3
3  0x00007ffff7312a25 in ?? () from /usr/lib/libdbus-1.so.3
4  0x00007ffff73050d6 in dbus_message_iter_append_basic () from /usr/lib/libdbus-1.so.3
5  0x0000000000433cc5 in get_replyto (property=<optimized out>, iter=<optimized out>,
    data=<optimized out>) at obexd/client/map.c:484
6  0x00000000004103b6 in append_property (p=p@entry=0x6594c0 <map_msg_properties+192>,
    dict=dict@entry=0x7fffffffd8e0, iface=0x6a3720) at gdbus/object.c:547
7  0x0000000000410472 in append_properties (data=data@entry=0x6a3720, iter=iter@entry=
    0x7fffffffd960) at gdbus/object.c:576
8  0x00000000004104d1 in append_interface (data=0x6a3720, user_data=0x7fffffffda40)
    at gdbus/object.c:591
9  0x00007ffff7058a4d in g_slist_foreach () from /usr/lib/libglib-2.0.so.0
10 0x0000000000411d05 in emit_interfaces_added (data=0x6a2ff0) at gdbus/object.c:623
11 process_changes (user_data=0x6a2ff0) at gdbus/object.c:1006
12 0x00007ffff703c845 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
13 0x00007ffff703cb78 in ?? () from /usr/lib/libglib-2.0.so.0
14 0x00007ffff703cf72 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
15 0x000000000040df82 in main (argc=1, argv=0x7fffffffdd88) at obexd/src/main.c:323
---
 obexd/client/map.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 68 insertions(+), 8 deletions(-)

diff --git a/obexd/client/map.c b/obexd/client/map.c
index 08914a6..635d951 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -435,6 +435,13 @@ done:
 	msg->pending = 0;
 }
 
+static gboolean subject_exists(const GDBusPropertyTable *property, void *data)
+{
+	struct map_msg *msg = data;
+
+	return msg->subject != NULL;
+}
+
 static gboolean get_subject(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -445,6 +452,13 @@ static gboolean get_subject(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean timestamp_exists(const GDBusPropertyTable *property, void *data)
+{
+	struct map_msg *msg = data;
+
+	return msg->timestamp != NULL;
+}
+
 static gboolean get_timestamp(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -455,6 +469,13 @@ static gboolean get_timestamp(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean sender_exists(const GDBusPropertyTable *property, void *data)
+{
+	struct map_msg *msg = data;
+
+	return msg->sender != NULL;
+}
+
 static gboolean get_sender(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -465,6 +486,14 @@ static gboolean get_sender(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean sender_address_exists(const GDBusPropertyTable *property,
+								void *data)
+{
+	struct map_msg *msg = data;
+
+	return msg->sender_address != NULL;
+}
+
 static gboolean get_sender_address(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -476,6 +505,13 @@ static gboolean get_sender_address(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean replyto_exists(const GDBusPropertyTable *property, void *data)
+{
+	struct map_msg *msg = data;
+
+	return msg->replyto != NULL;
+}
+
 static gboolean get_replyto(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -486,6 +522,13 @@ static gboolean get_replyto(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean recipient_exists(const GDBusPropertyTable *property, void *data)
+{
+	struct map_msg *msg = data;
+
+	return msg->recipient != NULL;
+}
+
 static gboolean get_recipient(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -496,6 +539,14 @@ static gboolean get_recipient(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean recipient_address_exists(const GDBusPropertyTable *property,
+								void *data)
+{
+	struct map_msg *msg = data;
+
+	return msg->recipient_address != NULL;
+}
+
 static gboolean get_recipient_address(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -507,6 +558,13 @@ static gboolean get_recipient_address(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean type_exists(const GDBusPropertyTable *property, void *data)
+{
+	struct map_msg *msg = data;
+
+	return msg->type != NULL;
+}
+
 static gboolean get_type(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -635,14 +693,16 @@ static const GDBusMethodTable map_msg_methods[] = {
 };
 
 static const GDBusPropertyTable map_msg_properties[] = {
-	{ "Subject", "s", get_subject },
-	{ "Timestamp", "s", get_timestamp },
-	{ "Sender", "s", get_sender },
-	{ "SenderAddress", "s", get_sender_address },
-	{ "ReplyTo", "s", get_replyto },
-	{ "Recipient", "s", get_recipient },
-	{ "RecipientAddress", "s", get_recipient_address },
-	{ "Type", "s", get_type },
+	{ "Subject", "s", get_subject, NULL, subject_exists },
+	{ "Timestamp", "s", get_timestamp, NULL, timestamp_exists },
+	{ "Sender", "s", get_sender, NULL, sender_exists },
+	{ "SenderAddress", "s", get_sender_address, NULL,
+						sender_address_exists },
+	{ "ReplyTo", "s", get_replyto, NULL, replyto_exists },
+	{ "Recipient", "s", get_recipient, NULL, recipient_exists },
+	{ "RecipientAddress", "s", get_recipient_address, NULL,
+						recipient_address_exists },
+	{ "Type", "s", get_type, NULL, type_exists },
 	{ "Size", "t", get_size },
 	{ "Priority", "b", get_priority },
 	{ "Read", "b", get_read, set_read },
-- 
1.8.1


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

* [PATCH 3/8] obexd: Fix infinite loop in ListMessages with filter "Types"
  2013-01-11 15:55 [PATCH 0/8] Obexd / MAP-client bug fixes Christian Fetzer
  2013-01-11 15:55 ` [PATCH 1/8] obexd: Handle empty path name in SetPath Christian Fetzer
  2013-01-11 15:55 ` [PATCH 2/8] obexd: Add property exist functions to map client Christian Fetzer
@ 2013-01-11 15:55 ` Christian Fetzer
  2013-01-11 15:55 ` [PATCH 4/8] obexd: Fix FILTER_ALL in MAP client to set 16 bit Christian Fetzer
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Christian Fetzer @ 2013-01-11 15:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Christian Fetzer

From: Christian Fetzer <christian.fetzer@bmw-carit.de>

Calls to ListMessages with filter 'Types' make obexd hang in an infinite loop.
This is caused by a missing dbus_message_iter_next in parse_filter_type.

0  0x00007ffff7304ca7 in dbus_message_iter_get_basic ()
   from /usr/lib/libdbus-1.so.3
1  0x0000000000434fba in parse_filter_type (iter=0x7fffffffd7d0, apparam=
    0x6987f0) at obexd/client/map.c:1086
2  parse_message_filters (iter=0x7fffffffd730, apparam=0x6987f0)
    at obexd/client/map.c:1222
3  map_list_messages (connection=<optimized out>, message=0x669ae0, user_data=
    0x698a60) at obexd/client/map.c:1273
4  0x00000000004109a1 in process_message (connection=0x662b20,
    message=<optimized out>, iface_user_data=<optimized out>,
    method=<optimized out>, method=<optimized out>) at gdbus/object.c:285
5  0x00007ffff7308e15 in ?? () from /usr/lib/libdbus-1.so.3
6  0x00007ffff72fb070 in dbus_connection_dispatch ()
   from /usr/lib/libdbus-1.so.3
7  0x000000000040e3d8 in message_dispatch (data=0x662b20)
    at gdbus/mainloop.c:76
8  0x00007ffff703d3cb in ?? () from /usr/lib/libglib-2.0.so.0
9  0x00007ffff703c845 in g_main_context_dispatch ()
   from /usr/lib/libglib-2.0.so.0
10 0x00007ffff703cb78 in ?? () from /usr/lib/libglib-2.0.so.0
11 0x00007ffff703cf72 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
12 0x000000000040df82 in main (argc=1, argv=0x7fffffffdd88)
    at obexd/src/main.c:323
---
 obexd/client/map.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/obexd/client/map.c b/obexd/client/map.c
index 635d951..afb5f9a 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -1123,6 +1123,8 @@ static GObexApparam *parse_filter_type(GObexApparam *apparam,
 			types |= 0x08; /* mms */
 		else
 			return NULL;
+
+		dbus_message_iter_next(&array);
 	}
 
 	return g_obex_apparam_set_uint8(apparam, MAP_AP_FILTERMESSAGETYPE,
-- 
1.8.1


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

* [PATCH 4/8] obexd: Fix FILTER_ALL in MAP client to set 16 bit
  2013-01-11 15:55 [PATCH 0/8] Obexd / MAP-client bug fixes Christian Fetzer
                   ` (2 preceding siblings ...)
  2013-01-11 15:55 ` [PATCH 3/8] obexd: Fix infinite loop in ListMessages with filter "Types" Christian Fetzer
@ 2013-01-11 15:55 ` Christian Fetzer
  2013-01-11 15:55 ` [PATCH 5/8] obexd: Fix segfault in parse_filter_read and parse_filter_priority Christian Fetzer
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Christian Fetzer @ 2013-01-11 15:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Christian Fetzer

From: Christian Fetzer <christian.fetzer@bmw-carit.de>

The MAP specification defines ParameterMask as a bitmask of 32 bit / 4 bytes.
For the lower 16 bit the specification defines parameters, the higher 16 bit
remain reserved for future use. Therefore FILTER_ALL is set to 0x0000FFFF.
(Reserved bits have to be set to 0)

In addition this fixes the issue that ListFilterFields didn't show all fields.
---
 obexd/client/map.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/obexd/client/map.c b/obexd/client/map.c
index afb5f9a..cea9369 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -75,7 +75,7 @@ static const char * const filter_list[] = {
 };
 
 #define FILTER_BIT_MAX	15
-#define FILTER_ALL	0xFF
+#define FILTER_ALL	0x0000FFFF
 
 #define STATUS_READ 0
 #define STATUS_DELETE 1
-- 
1.8.1


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

* [PATCH 5/8] obexd: Fix segfault in parse_filter_read and parse_filter_priority
  2013-01-11 15:55 [PATCH 0/8] Obexd / MAP-client bug fixes Christian Fetzer
                   ` (3 preceding siblings ...)
  2013-01-11 15:55 ` [PATCH 4/8] obexd: Fix FILTER_ALL in MAP client to set 16 bit Christian Fetzer
@ 2013-01-11 15:55 ` Christian Fetzer
  2013-01-11 15:55 ` [PATCH 6/8] obexd: Use defines for values in parse_filter_read parse_filter_priority Christian Fetzer
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Christian Fetzer @ 2013-01-11 15:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Christian Fetzer

From: Christian Fetzer <christian.fetzer@bmw-carit.de>

Calls to ListMessages with filter 'Read' or 'Priority' caused a segfault
in parse_filter_read / parse_filter_priority. The functions read
D-Bus boolean values (uint32) into uint8.

0  0x00007ffff730332d in ?? () from /usr/lib/libdbus-1.so.3
1  0x00007ffff7304219 in dbus_message_iter_next () from /usr/lib/libdbus-1.so.3
2  0x000000000043ef0f in parse_message_filters (
    apparam=<error reading variable: Cannot access memory at address 0x7ffffeffff08>,
    iter=<error reading variable: Cannot access memory at address 0x7ffffeffff00>)
    at obexd/client/map.c:1246
---
 obexd/client/map.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/obexd/client/map.c b/obexd/client/map.c
index cea9369..57ce1e6 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -1163,13 +1163,14 @@ static GObexApparam *parse_filter_read(GObexApparam *apparam,
 							DBusMessageIter *iter)
 {
 	guint8 status = 0;
+	dbus_bool_t dbus_status = FALSE;
 
 	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BOOLEAN)
 		return NULL;
 
-	dbus_message_iter_get_basic(iter, &status);
+	dbus_message_iter_get_basic(iter, &dbus_status);
 
-	status = (status) ? 0x01 : 0x02;
+	status = (dbus_status) ? 0x01 : 0x02;
 
 	return g_obex_apparam_set_uint8(apparam, MAP_AP_FILTERREADSTATUS,
 								status);
@@ -1207,13 +1208,14 @@ static GObexApparam *parse_filter_priority(GObexApparam *apparam,
 							DBusMessageIter *iter)
 {
 	guint8 priority;
+	dbus_bool_t dbus_priority = FALSE;
 
 	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BOOLEAN)
 		return NULL;
 
-	dbus_message_iter_get_basic(iter, &priority);
+	dbus_message_iter_get_basic(iter, &dbus_priority);
 
-	priority = (priority) ? 0x01 : 0x02;
+	priority = (dbus_priority) ? 0x01 : 0x02;
 
 	return g_obex_apparam_set_uint8(apparam, MAP_AP_FILTERPRIORITY,
 								priority);
-- 
1.8.1


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

* [PATCH 6/8] obexd: Use defines for values in parse_filter_read parse_filter_priority
  2013-01-11 15:55 [PATCH 0/8] Obexd / MAP-client bug fixes Christian Fetzer
                   ` (4 preceding siblings ...)
  2013-01-11 15:55 ` [PATCH 5/8] obexd: Fix segfault in parse_filter_read and parse_filter_priority Christian Fetzer
@ 2013-01-11 15:55 ` Christian Fetzer
  2013-01-11 15:55 ` [PATCH 7/8] obexd: Change behavior of parse_filter_read Christian Fetzer
  2013-01-11 15:55 ` [PATCH 8/8] obexd: Remove transferred file only if the GET operation failed Christian Fetzer
  7 siblings, 0 replies; 12+ messages in thread
From: Christian Fetzer @ 2013-01-11 15:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Christian Fetzer

From: Christian Fetzer <christian.fetzer@bmw-carit.de>

---
 obexd/client/map.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/obexd/client/map.c b/obexd/client/map.c
index 57ce1e6..3e4cde9 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -77,6 +77,14 @@ static const char * const filter_list[] = {
 #define FILTER_BIT_MAX	15
 #define FILTER_ALL	0x0000FFFF
 
+#define FILTER_READ_STATUS_NONE		0
+#define FILTER_READ_STATUS_ONLY_UNREAD	1
+#define FILTER_READ_STATUS_ONLY_READ	2
+
+#define FILTER_PRIORITY_NONE		0
+#define FILTER_PRIORITY_ONLY_HIGH	1
+#define FILTER_PRIORITY_ONLY_NONHIGH	2
+
 #define STATUS_READ 0
 #define STATUS_DELETE 1
 #define FILLER_BYTE 0x30
@@ -1162,7 +1170,7 @@ static GObexApparam *parse_period_end(GObexApparam *apparam,
 static GObexApparam *parse_filter_read(GObexApparam *apparam,
 							DBusMessageIter *iter)
 {
-	guint8 status = 0;
+	guint8 status = FILTER_READ_STATUS_NONE;
 	dbus_bool_t dbus_status = FALSE;
 
 	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BOOLEAN)
@@ -1170,7 +1178,10 @@ static GObexApparam *parse_filter_read(GObexApparam *apparam,
 
 	dbus_message_iter_get_basic(iter, &dbus_status);
 
-	status = (dbus_status) ? 0x01 : 0x02;
+	if (dbus_status)
+		status = FILTER_READ_STATUS_ONLY_UNREAD;
+	else
+		status = FILTER_READ_STATUS_ONLY_READ;
 
 	return g_obex_apparam_set_uint8(apparam, MAP_AP_FILTERREADSTATUS,
 								status);
@@ -1207,7 +1218,7 @@ static GObexApparam *parse_filter_sender(GObexApparam *apparam,
 static GObexApparam *parse_filter_priority(GObexApparam *apparam,
 							DBusMessageIter *iter)
 {
-	guint8 priority;
+	guint8 priority = FILTER_PRIORITY_NONE;
 	dbus_bool_t dbus_priority = FALSE;
 
 	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BOOLEAN)
@@ -1215,7 +1226,10 @@ static GObexApparam *parse_filter_priority(GObexApparam *apparam,
 
 	dbus_message_iter_get_basic(iter, &dbus_priority);
 
-	priority = (dbus_priority) ? 0x01 : 0x02;
+	if (dbus_priority)
+		priority = FILTER_PRIORITY_ONLY_HIGH;
+	else
+		priority = FILTER_PRIORITY_ONLY_NONHIGH;
 
 	return g_obex_apparam_set_uint8(apparam, MAP_AP_FILTERPRIORITY,
 								priority);
-- 
1.8.1


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

* [PATCH 7/8] obexd: Change behavior of parse_filter_read
  2013-01-11 15:55 [PATCH 0/8] Obexd / MAP-client bug fixes Christian Fetzer
                   ` (5 preceding siblings ...)
  2013-01-11 15:55 ` [PATCH 6/8] obexd: Use defines for values in parse_filter_read parse_filter_priority Christian Fetzer
@ 2013-01-11 15:55 ` Christian Fetzer
  2013-01-11 15:55 ` [PATCH 8/8] obexd: Remove transferred file only if the GET operation failed Christian Fetzer
  7 siblings, 0 replies; 12+ messages in thread
From: Christian Fetzer @ 2013-01-11 15:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Christian Fetzer

From: Christian Fetzer <christian.fetzer@bmw-carit.de>

Calls to ListMessages with filter 'Read' set to true should
request the MSE to send read messages only.

The old code requests the MSE to send unread messages only.
This behavior is not matching the other filters.
---
 obexd/client/map.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/obexd/client/map.c b/obexd/client/map.c
index 3e4cde9..99982c0 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -1179,9 +1179,9 @@ static GObexApparam *parse_filter_read(GObexApparam *apparam,
 	dbus_message_iter_get_basic(iter, &dbus_status);
 
 	if (dbus_status)
-		status = FILTER_READ_STATUS_ONLY_UNREAD;
-	else
 		status = FILTER_READ_STATUS_ONLY_READ;
+	else
+		status = FILTER_READ_STATUS_ONLY_UNREAD;
 
 	return g_obex_apparam_set_uint8(apparam, MAP_AP_FILTERREADSTATUS,
 								status);
-- 
1.8.1


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

* [PATCH 8/8] obexd: Remove transferred file only if the GET operation failed
  2013-01-11 15:55 [PATCH 0/8] Obexd / MAP-client bug fixes Christian Fetzer
                   ` (6 preceding siblings ...)
  2013-01-11 15:55 ` [PATCH 7/8] obexd: Change behavior of parse_filter_read Christian Fetzer
@ 2013-01-11 15:55 ` Christian Fetzer
  7 siblings, 0 replies; 12+ messages in thread
From: Christian Fetzer @ 2013-01-11 15:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Christian Fetzer

From: Christian Fetzer <christian.fetzer@bmw-carit.de>

Since 9606375649e12f1b9f302bbb5bb8f87957387ddd xfer_complete() sets the
transfer status rather than the size. Adapt obc_transfer_free to check
for the completed status to avoid deletion of completed transfers.
---
 obexd/client/transfer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c
index 541f405..427eab7 100644
--- a/obexd/client/transfer.c
+++ b/obexd/client/transfer.c
@@ -327,7 +327,8 @@ static void obc_transfer_free(struct obc_transfer *transfer)
 	}
 
 	if (transfer->op == G_OBEX_OP_GET &&
-					transfer->transferred != transfer->size)
+				transfer->status != TRANSFER_STATUS_COMPLETE &&
+				transfer->filename)
 		remove(transfer->filename);
 
 	if (transfer->fd > 0)
-- 
1.8.1


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

* Re: [PATCH 1/8] obexd: Handle empty path name in SetPath
  2013-01-11 15:55 ` [PATCH 1/8] obexd: Handle empty path name in SetPath Christian Fetzer
@ 2013-01-13 15:55   ` Luiz Augusto von Dentz
  2013-01-14 10:09     ` Christian Fetzer
  0 siblings, 1 reply; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2013-01-13 15:55 UTC (permalink / raw)
  To: Christian Fetzer; +Cc: linux-bluetooth@vger.kernel.org, Christian Fetzer

Hi Christian,

On Fri, Jan 11, 2013 at 5:55 PM, Christian Fetzer
<christian.fetzer@oss.bmw-carit.de> wrote:
> From: Christian Fetzer <christian.fetzer@bmw-carit.de>
>
> If the empty path is given, an empty name should be sent via OBEX.
> Currently the name field is not set at all and later checks which
> depend on data->index will access invalid memory regions as g_strsplit
> returns NULL when an empty string is given.
>
> 0  0x000000000041a181 in g_obex_setpath (obex=obex@entry=0x662eb0, path=
>     0x20 <Address 0x20 out of bounds>, func=func@entry=0x42d300 <setpath_cb>,
>     user_data=user_data@entry=0x668f10, err=err@entry=0x7fffffffda08)
>     at gobex/gobex.c:1397
> 1  0x000000000042d395 in setpath_cb (obex=0x662eb0, err=0x0, rsp=<optimized out>,
>     user_data=0x668f10) at obexd/client/session.c:902
> 2  0x0000000000418e54 in handle_response (obex=obex@entry=0x662eb0, err=err@entry=0x0,
>     rsp=rsp@entry=0x668f40) at gobex/gobex.c:948
> 3  0x0000000000419d7a in incoming_data (io=<optimized out>, cond=<optimized out>,
>     user_data=0x662eb0) at gobex/gobex.c:1191
> 4  0x00007ffff703c845 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
> 5  0x00007ffff703cb78 in ?? () from /usr/lib/libglib-2.0.so.0
> 6  0x00007ffff703cf72 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
> 7  0x000000000040def2 in main (argc=1, argv=0x7fffffffdd88) at obexd/src/main.c:323
> ---
>  obexd/client/session.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/obexd/client/session.c b/obexd/client/session.c
> index 9cc824e..db37a86 100644
> --- a/obexd/client/session.c
> +++ b/obexd/client/session.c
> @@ -934,7 +934,7 @@ guint obc_session_setpath(struct obc_session *session, const char *path,
>         p = pending_request_new(session, NULL, setpath_complete, data);
>
>         /* Relative path */
> -       if (path[0] != '/') {
> +       if (path[0] != '/' && path[0] != 0) {
>                 first = data->remaining[data->index];
>                 data->index++;
>         }
> --
> 1.8.1

But what empty means in this case, I would like to stick with cd
behavior, so empty should set back to root. Otherwise the patchset
seems fine.

--
Luiz Augusto von Dentz

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

* Re: [PATCH 1/8] obexd: Handle empty path name in SetPath
  2013-01-13 15:55   ` Luiz Augusto von Dentz
@ 2013-01-14 10:09     ` Christian Fetzer
  2013-01-14 17:33       ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 12+ messages in thread
From: Christian Fetzer @ 2013-01-14 10:09 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth@vger.kernel.org

Hi Luiz,

On 01/13/2013 04:55 PM, Luiz Augusto von Dentz wrote:
> But what empty means in this case, I would like to stick with cd 
> behavior, so empty should set back to root. Otherwise the patchset 
> seems fine. -- Luiz Augusto von Dentz 
But this is exactly what the patch is doing.
g_obex_setpath called with an empty path won't set the parent flag,
and thus it requests going back to the root folder.

< ACL data: handle 21 flags 0x00 dlen 21
     L2CAP(d): cid 0x0041 len 17 [psm 3]
       RFCOMM(d): UIH: cr 1 dlci 32 pf 0 ilen 13 fcs 0xd8
         OBEX: SetPath cmd(f): len 13 flags 2 constants 0
         Connection ID (0xcb) = 98
         Name (0x01) = Unicode length 0
 > HCI Event: Number of Completed Packets (0x13) plen 5
     handle 21 packets 1
 > ACL data: handle 21 flags 0x02 dlen 11
     L2CAP(d): cid 0x0041 len 7 [psm 3]
       RFCOMM(d): UIH: cr 0 dlci 32 pf 0 ilen 3 fcs 0x2
         OBEX: SetPath rsp(f): status 200 len 3

Or did I misunderstand you?

Regards,
Christian

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

* Re: [PATCH 1/8] obexd: Handle empty path name in SetPath
  2013-01-14 10:09     ` Christian Fetzer
@ 2013-01-14 17:33       ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2013-01-14 17:33 UTC (permalink / raw)
  To: Christian Fetzer; +Cc: linux-bluetooth@vger.kernel.org

Hi Christian,

On Mon, Jan 14, 2013 at 12:09 PM, Christian Fetzer
<christian.fetzer@oss.bmw-carit.de> wrote:
> Hi Luiz,
>
>
> On 01/13/2013 04:55 PM, Luiz Augusto von Dentz wrote:
>>
>> But what empty means in this case, I would like to stick with cd behavior,
>> so empty should set back to root. Otherwise the patchset seems fine. -- Luiz
>> Augusto von Dentz
>
> But this is exactly what the patch is doing.
> g_obex_setpath called with an empty path won't set the parent flag,
> and thus it requests going back to the root folder.
>
> < ACL data: handle 21 flags 0x00 dlen 21
>     L2CAP(d): cid 0x0041 len 17 [psm 3]
>       RFCOMM(d): UIH: cr 1 dlci 32 pf 0 ilen 13 fcs 0xd8
>         OBEX: SetPath cmd(f): len 13 flags 2 constants 0
>         Connection ID (0xcb) = 98
>         Name (0x01) = Unicode length 0
>> HCI Event: Number of Completed Packets (0x13) plen 5
>     handle 21 packets 1
>> ACL data: handle 21 flags 0x02 dlen 11
>     L2CAP(d): cid 0x0041 len 7 [psm 3]
>       RFCOMM(d): UIH: cr 0 dlci 32 pf 0 ilen 3 fcs 0x2
>         OBEX: SetPath rsp(f): status 200 len 3
>
> Or did I misunderstand you?

I was just confirming this would not cd back to parent, anyway this
set is now upstream, thanks!

Btw, Ive modified a little bit patch 06/08 to use hexadecimal values
to indicate better the size.


--
Luiz Augusto von Dentz

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

end of thread, other threads:[~2013-01-14 17:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-11 15:55 [PATCH 0/8] Obexd / MAP-client bug fixes Christian Fetzer
2013-01-11 15:55 ` [PATCH 1/8] obexd: Handle empty path name in SetPath Christian Fetzer
2013-01-13 15:55   ` Luiz Augusto von Dentz
2013-01-14 10:09     ` Christian Fetzer
2013-01-14 17:33       ` Luiz Augusto von Dentz
2013-01-11 15:55 ` [PATCH 2/8] obexd: Add property exist functions to map client Christian Fetzer
2013-01-11 15:55 ` [PATCH 3/8] obexd: Fix infinite loop in ListMessages with filter "Types" Christian Fetzer
2013-01-11 15:55 ` [PATCH 4/8] obexd: Fix FILTER_ALL in MAP client to set 16 bit Christian Fetzer
2013-01-11 15:55 ` [PATCH 5/8] obexd: Fix segfault in parse_filter_read and parse_filter_priority Christian Fetzer
2013-01-11 15:55 ` [PATCH 6/8] obexd: Use defines for values in parse_filter_read parse_filter_priority Christian Fetzer
2013-01-11 15:55 ` [PATCH 7/8] obexd: Change behavior of parse_filter_read Christian Fetzer
2013-01-11 15:55 ` [PATCH 8/8] obexd: Remove transferred file only if the GET operation failed Christian Fetzer

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