From 3e3dbe2e23ca19a947aedbc5e9e5e8caab3589f5 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Tue, 13 Oct 2015 18:28:40 +0200 Subject: [PATCH] Bluetooth: Fix Read Multiple Characteristics Values error response According to Core Specification "An Error Response shall be sent by the server in response to the Read Multiple Request if insufficient authentication, insufficient authorization, insufficient encryption key size is used by the client, or if a read operation is not permitted on any of the Characteristic Values. The Error Code parameter is set as specified in the Attribute Protocol." If any handle used by client is invalid we should return and error. Change-Id: I5489ce6284531822676a63edf13db23289866102 Signed-off-by: Szymon Janc --- net/bluetooth/att.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/bluetooth/att.c b/net/bluetooth/att.c index 0291bca605b..f50e746e5ca 100644 --- a/net/bluetooth/att.c +++ b/net/bluetooth/att.c @@ -785,6 +785,15 @@ static uint8_t att_read_mult_req(struct bt_conn *conn, struct bt_buf *buf) BT_DBG("handle 0x%04x \n", handle); + /* An Error Response shall be sent by the server in response to + * the Read Multiple Request [....] if a read operation is not + * permitted on any of the Characteristic Values. + * + * If handle is not valid then return invalid handle error. + * If handle is found error will be cleared by read_cb. + */ + data.err = BT_ATT_ERR_INVALID_HANDLE; + bt_gatt_foreach_attr(handle, handle, read_cb, &data); /* Stop reading in case of error */