Linux bluetooth development
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Lukasz Rymanowski <lukasz.rymanowski@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 15/16] shared/gatt-helpers: Improve robustness read by type request
Date: Fri, 27 Feb 2015 16:07:01 +0100	[thread overview]
Message-ID: <5548555.j9qucFdfti@uw000953> (raw)
In-Reply-To: <1424943583-30061-16-git-send-email-lukasz.rymanowski@tieto.com>

Hi Łukasz,

On Thursday 26 of February 2015 10:39:42 Lukasz Rymanowski wrote:
> This patch makes sure that we do get into infinite loop when doing
> read by type request.
> 
> It could happen if we got bogus read by type response
> ---
>  src/shared/gatt-helpers.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c
> index 8858e58..6e5cf30 100644
> --- a/src/shared/gatt-helpers.c
> +++ b/src/shared/gatt-helpers.c
> @@ -1331,10 +1331,22 @@ static void read_by_type_cb(uint8_t opcode, const void *pdu,
>  	}
>  
>  	last_handle = get_le16(pdu + length - data_length);
> +
> +	/*
> +	 * If last handle is lower from previous start handle then it is smth
> +	 * wrong. Let's stop search, otherwise we might enter infinite loop.
> +	 */
> +	if (last_handle < op->start_handle) {
> +		success = true;
> +		goto done;
> +	}

Shouldn't this be success = false ?

> +
> +	op->start_handle = last_handle + 1;
> +
>  	if (last_handle != op->end_handle) {
>  		uint8_t pdu[4 + get_uuid_len(&op->uuid)];
>  
> -		put_le16(last_handle + 1, pdu);
> +		put_le16(op->start_handle, pdu);
>  		put_le16(op->end_handle, pdu + 2);
>  		bt_uuid_to_le(&op->uuid, pdu + 4);
>  
> @@ -1376,6 +1388,7 @@ bool bt_gatt_read_by_type(struct bt_att *att, uint16_t start, uint16_t end,
>  	op->callback = callback;
>  	op->user_data = user_data;
>  	op->destroy = destroy;
> +	op->start_handle = start;
>  	op->end_handle = end;
>  	op->uuid = *uuid;
>  
> 

-- 
Best regards, 
Szymon Janc

  reply	other threads:[~2015-02-27 15:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26  9:39 [PATCH 00/16] android/gatt: Improve robustness in Gatt Client Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 01/16] android/tester-gatt: Add robustness test for search services Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 02/16] attrib/gatt: Improve robustness on search primary services Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 03/16] android/tester-gatt: Add robustness test for get characteristic Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 04/16] attrib/gatt: Minor refactor in char_discovered_cb Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 05/16] attrib/gatt: Improve robustness when searching for characteristics Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 06/16] android/gatt: Check status on get characteristic callback Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 07/16] android/tester: Add robustness test for get descriptor Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 08/16] attrib/gatt: Minor refactor in desc_discovered_cb Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 09/16] attrib/gatt: Improve robustness when searching for descriptors Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 10/16] android/tester: Add robustness test for get included services Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 11/16] attrib/gatt: Improve robustness when searching for " Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 12/16] shated/gatt-helpers: Improve robustness of search service Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 13/16] shared/gatt-helpers: Improve robustness of get characteristics Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 14/16] shared/gatt-helpers: Improve robustness of get include services Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 15/16] shared/gatt-helpers: Improve robustness read by type request Lukasz Rymanowski
2015-02-27 15:07   ` Szymon Janc [this message]
2015-02-27 15:14     ` Lukasz Rymanowski
2015-02-26  9:39 ` [PATCH 16/16] shared/gatt-helpers: Improve robustness of get descriptors Lukasz Rymanowski
2015-02-27 15:35 ` [PATCH 00/16] android/gatt: Improve robustness in Gatt Client Szymon Janc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5548555.j9qucFdfti@uw000953 \
    --to=szymon.janc@tieto.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=lukasz.rymanowski@tieto.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox