From 8c89636ae69c64e6e60eea3f93496f9c4013a324 Mon Sep 17 00:00:00 2001 From: Jakub Tyszkowski Date: Fri, 19 Dec 2014 07:50:14 +0100 Subject: [PATCH] android/gatt: Report error on invalid value length for CCC descriptor 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 37e4454c0..fd9540087 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -6988,8 +6988,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); } -- 2.47.3