linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH obexd] client: fix parsing of apparam on pbap driver
@ 2012-01-14  9:53 Luiz Augusto von Dentz
  2012-01-16 14:52 ` Syam Sidhardhan
  0 siblings, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2012-01-14  9:53 UTC (permalink / raw)
  To: linux-bluetooth

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

Header pointer need to be updated otherwise the code will be stuck in the
first parameter even though the size is updated.
---
 client/pbap.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/client/pbap.c b/client/pbap.c
index 9e9eb05..1da0ae5 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -364,7 +364,7 @@ static void read_return_apparam(struct obc_session *session,
 {
 	struct obc_transfer *transfer = obc_session_get_transfer(session);
 	struct obc_transfer_params params;
-	unsigned char *buf;
+	struct apparam_hdr *hdr;
 	size_t size = 0;
 
 	*phone_book_size = 0;
@@ -376,9 +376,9 @@ static void read_return_apparam(struct obc_session *session,
 	if (params.size < APPARAM_HDR_SIZE)
 		return;
 
-	while (size > APPARAM_HDR_SIZE) {
-		struct apparam_hdr *hdr = (struct apparam_hdr *) params.data;
+	hdr = (struct apparam_hdr *) params.data;
 
+	while (size > APPARAM_HDR_SIZE) {
 		if (hdr->len > size - APPARAM_HDR_SIZE) {
 			error("Unexpected PBAP pullphonebook app"
 					" length, tag %d, len %d",
@@ -404,7 +404,7 @@ static void read_return_apparam(struct obc_session *session,
 					hdr->tag, hdr->len);
 		}
 
-		buf += APPARAM_HDR_SIZE + hdr->len;
+		hdr += APPARAM_HDR_SIZE + hdr->len;
 		size -= APPARAM_HDR_SIZE + hdr->len;
 	}
 }
-- 
1.7.7.5


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

* Re: [PATCH obexd] client: fix parsing of apparam on pbap driver
  2012-01-14  9:53 Luiz Augusto von Dentz
@ 2012-01-16 14:52 ` Syam Sidhardhan
  2012-01-16 15:02   ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 4+ messages in thread
From: Syam Sidhardhan @ 2012-01-16 14:52 UTC (permalink / raw)
  To: Luiz Augusto von Dentz, linux-bluetooth

Hi Luiz,

----- Original Message ----- 
From: "Luiz Augusto von Dentz" <luiz.dentz@gmail.com>
To: <linux-bluetooth@vger.kernel.org>
Sent: Saturday, January 14, 2012 3:23 PM
Subject: [PATCH obexd] client: fix parsing of apparam on pbap driver


> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> Header pointer need to be updated otherwise the code will be stuck in the
> first parameter even though the size is updated.
> ---
> client/pbap.c |    8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/client/pbap.c b/client/pbap.c
> index 9e9eb05..1da0ae5 100644
> --- a/client/pbap.c
> +++ b/client/pbap.c
> @@ -364,7 +364,7 @@ static void read_return_apparam(struct obc_session 
> *session,
> {
>  struct obc_transfer *transfer = obc_session_get_transfer(session);
>  struct obc_transfer_params params;
> - unsigned char *buf;
> + struct apparam_hdr *hdr;
>  size_t size = 0;
>
>  *phone_book_size = 0;
> @@ -376,9 +376,9 @@ static void read_return_apparam(struct obc_session 
> *session,
>  if (params.size < APPARAM_HDR_SIZE)
>  return;
>
> - while (size > APPARAM_HDR_SIZE) {
> - struct apparam_hdr *hdr = (struct apparam_hdr *) params.data;
> + hdr = (struct apparam_hdr *) params.data;
>
> + while (size > APPARAM_HDR_SIZE) {
>  if (hdr->len > size - APPARAM_HDR_SIZE) {
>  error("Unexpected PBAP pullphonebook app"
>  " length, tag %d, len %d",
> @@ -404,7 +404,7 @@ static void read_return_apparam(struct obc_session 
> *session,
>  hdr->tag, hdr->len);
>  }
>
> - buf += APPARAM_HDR_SIZE + hdr->len;
> + hdr += APPARAM_HDR_SIZE + hdr->len;
>  size -= APPARAM_HDR_SIZE + hdr->len;
>  }
> }

Here one more changes is required. Since we are not updating the size
while (size > APPARAM_HDR_SIZE) statement will always evaluate as false
and it will never enter into the loop. So we need to have a statement
size = params.size; before checking for the while() condition. Correct me if 
I 'm wrong here.

Thanks,
Syam

> -- 
> 1.7.7.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" 
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html 


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

* Re: [PATCH obexd] client: fix parsing of apparam on pbap driver
  2012-01-16 14:52 ` Syam Sidhardhan
@ 2012-01-16 15:02   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2012-01-16 15:02 UTC (permalink / raw)
  To: Syam Sidhardhan; +Cc: linux-bluetooth

Hi Syam,

On Mon, Jan 16, 2012 at 4:52 PM, Syam Sidhardhan <s.syam@samsung.com> wrote:
> Here one more changes is required. Since we are not updating the size
> while (size > APPARAM_HDR_SIZE) statement will always evaluate as false
> and it will never enter into the loop. So we need to have a statement
> size = params.size; before checking for the while() condition. Correct me if
> I 'm wrong here.

Yep, gonna fix that too, thanks for the feedback.


-- 
Luiz Augusto von Dentz

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

* [PATCH obexd] client: fix parsing of apparam on pbap driver
@ 2012-01-17 10:15 Luiz Augusto von Dentz
  0 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2012-01-17 10:15 UTC (permalink / raw)
  To: linux-bluetooth

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

Both hdr and size need to be updated otherwise no parameters will be
parsed.
---
 client/pbap.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/client/pbap.c b/client/pbap.c
index 9e9eb05..84465ac 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -364,8 +364,8 @@ static void read_return_apparam(struct obc_session *session,
 {
 	struct obc_transfer *transfer = obc_session_get_transfer(session);
 	struct obc_transfer_params params;
-	unsigned char *buf;
-	size_t size = 0;
+	struct apparam_hdr *hdr;
+	size_t size;
 
 	*phone_book_size = 0;
 	*new_missed_calls = 0;
@@ -376,9 +376,10 @@ static void read_return_apparam(struct obc_session *session,
 	if (params.size < APPARAM_HDR_SIZE)
 		return;
 
-	while (size > APPARAM_HDR_SIZE) {
-		struct apparam_hdr *hdr = (struct apparam_hdr *) params.data;
+	hdr = (struct apparam_hdr *) params.data;
+	size = params.size;
 
+	while (size > APPARAM_HDR_SIZE) {
 		if (hdr->len > size - APPARAM_HDR_SIZE) {
 			error("Unexpected PBAP pullphonebook app"
 					" length, tag %d, len %d",
@@ -404,7 +405,7 @@ static void read_return_apparam(struct obc_session *session,
 					hdr->tag, hdr->len);
 		}
 
-		buf += APPARAM_HDR_SIZE + hdr->len;
+		hdr += APPARAM_HDR_SIZE + hdr->len;
 		size -= APPARAM_HDR_SIZE + hdr->len;
 	}
 }
-- 
1.7.7.5


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

end of thread, other threads:[~2012-01-17 10:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-17 10:15 [PATCH obexd] client: fix parsing of apparam on pbap driver Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2012-01-14  9:53 Luiz Augusto von Dentz
2012-01-16 14:52 ` Syam Sidhardhan
2012-01-16 15:02   ` 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).