Linux bluetooth development
 help / color / mirror / Atom feed
* Fwd: Fwd: Fwd: [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error
@ 2015-06-11  4:09 Nagaraj D R
  2015-06-11  9:54 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Nagaraj D R @ 2015-06-11  4:09 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org

cGluZw0KDQotLS0tLS0tIE9yaWdpbmFsIE1lc3NhZ2UgLS0tLS0tLQ0KU2VuZGVyIDogTmFnYXJh
aiBEIFIgTGVhZCBFbmdpbmVlci9TUkktQmFuZ2Fsb3JlLVN5c3RlbSAmIENvbm5lY3Rpdml0eS9T
YW1zdW5nIEVsZWN0cm9uaWNzDQpEYXRlIDogTWF5IDE1LCAyMDE1IDExOjUwIChHTVQrMDU6MzAp
DQpUaXRsZSA6IEZ3ZDogW1BBVENIIDEvMV0gc2hhcmVkL2dhdHQtY2xpZW50OiBGaXggdGhlICJG
aW5kIEluZm9ybWF0aW9uIHJlcSIgZXJyb3INCg0KcGluZw0KDQotLS0tLS0tIE9yaWdpbmFsIE1l
c3NhZ2UgLS0tLS0tLQ0KU2VuZGVyIDogTmFnYXJhaiBEIFIgTGVhZCBFbmdpbmVlci9TUkktQmFu
Z2Fsb3JlLVN5c3RlbSAmIENvbm5lY3Rpdml0eS9TYW1zdW5nIEVsZWN0cm9uaWNzDQpEYXRlIDog
TWF5IDEzLCAyMDE1IDE3OjA1IChHTVQrMDU6MzApDQpUaXRsZSA6IFtQQVRDSCAxLzFdIHNoYXJl
ZC9nYXR0LWNsaWVudDogRml4IHRoZSAiRmluZCBJbmZvcm1hdGlvbiByZXEiIGVycm9yDQoNCkZy
b206ICJuYWdhcmFqLmRyIiANCg0KY2hhcmFjdGVyaXN0aWMgZGVzY3JpcHRvciBpcyBzZWFyY2hl
ZCBiL3cgdGhlDQpjaGFyYWN0ZXJpc3RpYyAidmFsdWVfaGFuZGxlICsgMSIgYW5kDQpjaGFyYW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2F0dC1jbGllbnQuYyBiL3NyYy9z
aGFyZWQvZ2F0dC1jbGllbnQuYw0KaW5kZXggN2JjM2I3MS4uOWI5NDRlZSAxMDA2NDQNCi0tLSBh
L3NyYy9zaGFyZWQvZ2F0dC1jbGllbnQuYw0KKysrIGIvc3JjL3NoYXJlZC9nYXR0LWNsaWVudC5j
DQpAQCAtNjAxLDEzICs2MDEsMTMgQEAgc3RhdGljIGJvb2wgZGlzY292ZXJfZGVzY3Moc3RydWN0
IGRpc2NvdmVyeV9vcCAqb3AsIGJvb2wgKmRpc2NvdmVyaW5nKQ0KY2hyY19kYXRhLT52YWx1ZV9o
YW5kbGUpDQpnb3RvIGZhaWxlZDsNCg0KLSBkZXNjX3N0YXJ0ID0gY2hyY19kYXRhLT52YWx1ZV9o
YW5kbGUgKyAxOw0KLQ0KLSBpZiAoZGVzY19zdGFydCA+IGNocmNfZGF0YS0+ZW5kX2hhbmRsZSkg
ew0KKyBpZiAoY2hyY19kYXRhLT52YWx1ZV9oYW5kbGUgPj0gY2hyY19kYXRhLT5lbmRfaGFuZGxl
KSB7DQpmcmVlKGNocmNfZGF0YSk7DQpjb250aW51ZTsNCn0NCg0KKyBkZXNjX3N0YXJ0ID0gY2hy
Y19kYXRhLT52YWx1ZV9oYW5kbGUgKyAxOw0KKw0KY2xpZW50LT5kaXNjb3ZlcnlfcmVxID0gYnRf
Z2F0dF9kaXNjb3Zlcl9kZXNjcmlwdG9ycygNCmNsaWVudC0+YXR0LCBkZXNjX3N0YXJ0LA0KY2hy
Y19kYXRhLT5lbmRfaGFuZGxlLA0KLS0gDQoxLjcuOS41



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

* Re: Fwd: Fwd: [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error
  2015-06-11  4:09 Fwd: Fwd: Fwd: [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error Nagaraj D R
@ 2015-06-11  9:54 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2015-06-11  9:54 UTC (permalink / raw)
  To: nagaraj.dr; +Cc: linux-bluetooth@vger.kernel.org

Hi Nagaraj,

On Thu, Jun 11, 2015 at 7:09 AM, Nagaraj D R <nagaraj.dr@samsung.com> wrote:
> ping
>
> ------- Original Message -------
> Sender : Nagaraj D R Lead Engineer/SRI-Bangalore-System & Connectivity/Samsung Electronics
> Date : May 15, 2015 11:50 (GMT+05:30)
> Title : Fwd: [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error
>
> ping
>
> ------- Original Message -------
> Sender : Nagaraj D R Lead Engineer/SRI-Bangalore-System & Connectivity/Samsung Electronics
> Date : May 13, 2015 17:05 (GMT+05:30)
> Title : [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error
>
> From: "nagaraj.dr"
>
> characteristic descriptor is searched b/w the
> characteristic "value_handle + 1" and
> characteristic "end_handle" using "Find Information req"
>
> if remote device had declared the characteristic value_handle
> at 0XFFFF (which also means there is no characteristic descriptors),then
> present code would make start_handle has 0X0000(because of 16 bit
> integer overflow) for "Find Information req"
>
> desc_start = chrc_data->value_handle + 1;
>
> Consequence:  Below request will be sent,
>         ATT: Find Information req (0x04)
>         start 0x0000, end 0xffff
>
>         and below will be the proper response from the remote device
>         ATT: Error (0x01)
>         Error: Invalid handle (1)
>         Find Information req (0x04) on handle 0x0000
> ---
> src/shared/gatt-client.c |    6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
> index 7bc3b71..9b944ee 100644
> --- a/src/shared/gatt-client.c
> +++ b/src/shared/gatt-client.c
> @@ -601,13 +601,13 @@ static bool discover_descs(struct discovery_op *op, bool *discovering)
> chrc_data->value_handle)
> goto failed;

Actually this check should happen in
gatt_db_service_insert_characteristic which is probably creating
something with handle 0 in the database which is wrong, actually
perhaps it should just fail to create a characteristic in 0xffff,
characteristics shall always have a value descriptor:

3.3.2 Characteristic Value Declaration
The Characteristic Value declaration contains the value of the
characteristic. It
is the first Attribute after the characteristic declaration. All characteristic
definitions shall have a Characteristic Value declaration.

So I would suggest something like this:

iff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 5e1537e..7f863ef 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -706,6 +706,18 @@ service_insert_characteristic(struct
gatt_db_service *service,
        if (handle && handle <= service->attributes[0]->handle)
                return NULL;

+       /*
+        * It is not possible to allocate last handle for a Characteristic
+        * since it would not have space for its value:
+        * 3.3.2 Characteristic Value Declaration
+        * The Characteristic Value declaration contains the value of the
+        * characteristic. It is the first Attribute after the characteristic
+        * declaration. All characteristic definitions shall have a
+        * Characteristic Value declaration.
+        */
+       if (handle == UINT16_MAX)
+               return NULL;
+
        i = get_attribute_index(service, 1);
        if (!i)
                return NULL;

-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2015-06-11  9:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-11  4:09 Fwd: Fwd: Fwd: [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error Nagaraj D R
2015-06-11  9:54 ` 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