linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2] android/gatt: Report error on invalid value length for CCC descriptor
@ 2014-12-19  6:50 Jakub Tyszkowski
  2014-12-19 13:10 ` Szymon Janc
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Tyszkowski @ 2014-12-19  6:50 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

For application services, characteristics and descriptors it's user
app's responsibility to verify value length but for embeded ones we
need to do this in daemon. This is checked in TC_GAW_SR_BI_34_C and
PTS tries to write to embeded CCC descritor if no other descriptors
are added by the apps. It is expected by PTS for us to be more strict
about value length controll.
---
 android/gatt.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/android/gatt.c b/android/gatt.c
index 0258d91..76df029 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -6961,8 +6961,15 @@ static void gatt_srvc_change_write_cb(struct gatt_db_attribute *attrib,
 		return;
 	}
 
+	/* 2 octets are expected as CCC value */
+	if (len != 2) {
+		gatt_db_attribute_write_result(attrib, id,
+						ATT_ECODE_INVAL_ATTR_VALUE_LEN);
+		return;
+	}
+
 	/* Set services changed indication value */
-	bt_store_gatt_ccc(bdaddr, *value);
+	bt_store_gatt_ccc(bdaddr, get_le16(value));
 
 	gatt_db_attribute_write_result(attrib, id, 0);
 }
-- 
1.9.1


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

* Re: [PATCHv2] android/gatt: Report error on invalid value length for CCC descriptor
  2014-12-19  6:50 [PATCHv2] android/gatt: Report error on invalid value length for CCC descriptor Jakub Tyszkowski
@ 2014-12-19 13:10 ` Szymon Janc
  0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2014-12-19 13:10 UTC (permalink / raw)
  To: Jakub Tyszkowski; +Cc: linux-bluetooth

Hi Jakub,

On Friday 19 of December 2014 07:50:14 Jakub Tyszkowski wrote:
> For application services, characteristics and descriptors it's user
> app's responsibility to verify value length but for embeded ones we
> need to do this in daemon. This is checked in TC_GAW_SR_BI_34_C and
> PTS tries to write to embeded CCC descritor if no other descriptors
> are added by the apps. It is expected by PTS for us to be more strict
> about value length controll.
> ---
>  android/gatt.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/android/gatt.c b/android/gatt.c
> index 0258d91..76df029 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -6961,8 +6961,15 @@ static void gatt_srvc_change_write_cb(struct gatt_db_attribute *attrib,
>  		return;
>  	}
>  
> +	/* 2 octets are expected as CCC value */
> +	if (len != 2) {
> +		gatt_db_attribute_write_result(attrib, id,
> +						ATT_ECODE_INVAL_ATTR_VALUE_LEN);
> +		return;
> +	}
> +
>  	/* Set services changed indication value */
> -	bt_store_gatt_ccc(bdaddr, *value);
> +	bt_store_gatt_ccc(bdaddr, get_le16(value));
>  
>  	gatt_db_attribute_write_result(attrib, id, 0);
>  }
> 

Applied, thanks.

-- 
Best regards, 
Szymon Janc

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

end of thread, other threads:[~2014-12-19 13:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-19  6:50 [PATCHv2] android/gatt: Report error on invalid value length for CCC descriptor Jakub Tyszkowski
2014-12-19 13:10 ` Szymon Janc

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).