All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix not responding Not Found when no entry is found
@ 2010-10-14 13:34 Luiz Augusto von Dentz
  2010-10-14 20:35 ` Johan Hedberg
  0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2010-10-14 13:34 UTC (permalink / raw)
  To: linux-bluetooth

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

Accourding to PBAP spec PSE must reply Not Found when:

"The function was recognized and all the parameters are proper, but the
vCard handle or the phone book object could not be found."
---
 plugins/pbap.c              |   15 +++++++++++++++
 plugins/phonebook-tracker.c |   12 +++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/plugins/pbap.c b/plugins/pbap.c
index 948f9df..13742da 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -228,6 +228,9 @@ static void phonebook_size_result(const char *buffer, size_t bufsize,
 	struct aparam_header *hdr = (struct aparam_header *) aparam;
 	uint16_t phonebooksize;
 
+	if (vcards < 0)
+		vcards = 0;
+
 	DBG("vcards %d", vcards);
 
 	phonebooksize = htons(vcards);
@@ -248,6 +251,11 @@ static void query_result(const char *buffer, size_t bufsize, int vcards,
 
 	DBG("");
 
+	if (vcards < 0) {
+		obex_object_set_io_flags(pbap, G_IO_ERR, -ENOENT);
+		return;
+	}
+
 	if (!pbap->buffer)
 		pbap->buffer = g_string_new_len(buffer, bufsize);
 	else
@@ -389,6 +397,13 @@ static void cache_ready_notify(void *user_data)
 		pbap->buffer = g_string_new_len(aparam, sizeof(aparam));
 		goto done;
 	}
+
+	if (pbap->cache.entries == NULL) {
+		pbap->cache.valid = TRUE;
+		obex_object_set_io_flags(pbap, G_IO_ERR, -ENOENT);
+		return;
+	}
+
 	/*
 	 * Don't free the sorted list content: this list contains
 	 * only the reference for the "real" cache entry.
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 39e4c81..2da825b 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -924,6 +924,11 @@ static void pull_contacts(char **reply, int num_fields, void *user_data)
 	gboolean cdata_present = FALSE;
 	char *home_addr, *work_addr;
 
+	if (num_fields < 0) {
+		data->cb(NULL, 0, num_fields, 0, data->user_data);
+		goto fail;
+	}
+
 	DBG("reply %p", reply);
 
 	if (reply == NULL)
@@ -1031,8 +1036,9 @@ done:
 				g_slist_length(data->contacts), 0,
 				data->user_data);
 
-	g_slist_free(data->contacts);
 	g_string_free(vcards, TRUE);
+fail:
+	g_slist_free(data->contacts);
 	g_free(data);
 }
 
@@ -1042,7 +1048,7 @@ static void add_to_cache(char **reply, int num_fields, void *user_data)
 	char *formatted;
 	int i;
 
-	if (reply == NULL)
+	if (reply == NULL || num_fields < 0)
 		goto done;
 
 	/* the first element is the URI, always not empty */
@@ -1075,7 +1081,7 @@ static void add_to_cache(char **reply, int num_fields, void *user_data)
 	return;
 
 done:
-	if (num_fields == 0)
+	if (num_fields <= 0)
 		cache->ready_cb(cache->user_data);
 
 	g_free(cache);
-- 
1.7.1


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

* Re: [PATCH] Fix not responding Not Found when no entry is found
  2010-10-14 13:34 [PATCH] Fix not responding Not Found when no entry is found Luiz Augusto von Dentz
@ 2010-10-14 20:35 ` Johan Hedberg
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2010-10-14 20:35 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Thu, Oct 14, 2010, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
> 
> Accourding to PBAP spec PSE must reply Not Found when:
> 
> "The function was recognized and all the parameters are proper, but the
> vCard handle or the phone book object could not be found."
> ---
>  plugins/pbap.c              |   15 +++++++++++++++
>  plugins/phonebook-tracker.c |   12 +++++++++---
>  2 files changed, 24 insertions(+), 3 deletions(-)

Pushed upstream. Thanks.

Johan

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

end of thread, other threads:[~2010-10-14 20:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-14 13:34 [PATCH] Fix not responding Not Found when no entry is found Luiz Augusto von Dentz
2010-10-14 20:35 ` Johan Hedberg

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.