client: fix parsing of apparam on pbap driver
Luiz Augusto von Dentz
maintainerPATCH 1/1 client: fix parsing of apparam on pbap driver
From: Luiz Augusto von Dentz <[email protected]>
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(-)
client/pbap.c +4 -4
@@ -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; } }
Signature · 1 line
1.7.7.5
Hi Luiz,
----- Original Message ----- From: "Luiz Augusto von Dentz" <[email protected]>
To: <[email protected]>
Sent: Saturday, January 14, 2012 3:23 PM
Subject: [PATCH obexd] client: fix parsing of apparam on pbap driver
Quoted 44 lines
From: Luiz Augusto von Dentz <[email protected]>
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(-)client/pbap.c +1
-1@@ -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;client/pbap.c +2
-2@@ -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",
client/pbap.c +1
-1@@ -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; }
Quoted 1 line
}
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
Quoted 7 lines
Signature · 6 lines
1.7.7.5 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Luiz Augusto von Dentz
maintainerHi Syam,
Quoted 5 lines · Syam Sidhardhan
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 thewhile()condition. Correct me if I 'm wrong here.
Yep, gonna fix that too, thanks for the feedback.
Signature · 1 line
Luiz Augusto von Dentz