* Fwd: Fwd: [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error
@ 2015-05-25 5:47 Nagaraj D R
0 siblings, 0 replies; 2+ messages in thread
From: Nagaraj D R @ 2015-05-25 5:47 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org, nagaraj.dr
cGluZw0KDQotLS0tLS0tIE9yaWdpbmFsIE1lc3NhZ2UgLS0tLS0tLQ0KU2VuZGVyIDogTmFnYXJh
aiBEIFI8bmFnYXJhai5kckBzYW1zdW5nLmNvbT4gTGVhZCBFbmdpbmVlci9TUkktQmFuZ2Fsb3Jl
LVN5c3RlbSAmIENvbm5lY3Rpdml0eS9TYW1zdW5nIEVsZWN0cm9uaWNzDQpEYXRlIDogTWF5IDE1
LCAyMDE1IDExOjUwIChHTVQrMDU6MzApDQpUaXRsZSA6IEZ3ZDogW1BBVENIIDEvMV0gc2hhcmVk
L2dhdHQtY2xpZW50OiBGaXggdGhlICJGaW5kIEluZm9ybWF0aW9uIHJlcSIgZXJyb3INCg0KcGlu
Zw0KDQotLS0tLS0tIE9yaWdpbmFsIE1lc3NhZ2UgLS0tLS0tLQ0KU2VuZGVyIDogTmFnYXJhaiBE
IFIgTGVhZCBFbmdpbmVlci9TUkktQmFuZ2Fsb3JlLVN5c3RlbSAmIENvbm5lY3Rpdml0eS9TYW1z
dW5nIEVsZWN0cm9uaWNzDQpEYXRlIDogTWF5IDEzLCAyMDE1IDE3OjA1IChHTVQrMDU6MzApDQpU
aXRsZSA6IFtQQVRDSCAxLzFdIHNoYXJlZC9nYXR0LWNsaWVudDogRml4IHRoZSAiRmluZCBJbmZv
cm1hdGlvbiByZXEiIGVycm9yDQoNCkZyb206ICJuYWdhcmFqLmRyIiANCg0KY2hhcmFjdGVyaXN0
aWMgZGVzY3JpcHRvciBpcyBzZWFyY2hlZCBiL3cgdGhlDQpjaGFyYWN0ZXJpc3RpYyAidmFsdWVf
aGFuZGxlICsgMSIgYW5kDQpjaGFyYWN0ZXJpc3RpYyAiZW5kX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y9zaGFyZWQvZ2F0dC1jbGllbnQuYw0KaW5kZXggN2JjM2I3
MS4uOWI5NDRlZSAxMDA2NDQNCi0tLSBhL3NyYy9zaGFyZWQvZ2F0dC1jbGllbnQuYw0KKysrIGIv
c3JjL3NoYXJlZC9nYXR0LWNsaWVudC5jDQpAQCAtNjAxLDEzICs2MDEsMTMgQEAgc3RhdGljIGJv
b2wgZGlzY292ZXJfZGVzY3Moc3RydWN0IGRpc2NvdmVyeV9vcCAqb3AsIGJvb2wgKmRpc2NvdmVy
aW5nKQ0KY2hyY19kYXRhLT52YWx1ZV9oYW5kbGUpDQpnb3RvIGZhaWxlZDsNCg0KLSBkZXNjX3N0
YXJ0ID0gY2hyY19kYXRhLT52YWx1ZV9oYW5kbGUgKyAxOw0KLQ0KLSBpZiAoZGVzY19zdGFydCA+
IGNocmNfZGF0YS0+ZW5kX2hhbmRsZSkgew0KKyBpZiAoY2hyY19kYXRhLT52YWx1ZV9oYW5kbGUg
Pj0gY2hyY19kYXRhLT5lbmRfaGFuZGxlKSB7DQpmcmVlKGNocmNfZGF0YSk7DQpjb250aW51ZTsN
Cn0NCg0KKyBkZXNjX3N0YXJ0ID0gY2hyY19kYXRhLT52YWx1ZV9oYW5kbGUgKyAxOw0KKw0KY2xp
ZW50LT5kaXNjb3ZlcnlfcmVxID0gYnRfZ2F0dF9kaXNjb3Zlcl9kZXNjcmlwdG9ycygNCmNsaWVu
dC0+YXR0LCBkZXNjX3N0YXJ0LA0KY2hyY19kYXRhLT5lbmRfaGFuZGxlLA0KLS0gDQoxLjcuOS41
^ 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: " 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-05-25 5:47 Fwd: Fwd: [PATCH 1/1] shared/gatt-client: Fix the "Find Information req" error Nagaraj D R
-- strict thread matches above, loose matches on Subject: below --
2015-06-11 4:09 Fwd: " 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;
as well as URLs for NNTP newsgroup(s).