Bluetooth: GATT: Add missing LESC_MASK for encrypt check

The LE Secure connection (LESC) mask also require encryption,
and some users have been using e.g. BT_GATT_PERM_READ_LESC
without BT_GATT_PERM_READ_ENCRYPT, and then the encryption
check in bt_gatt_check_perm was never properly applied.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2024-02-19 09:29:28 +01:00 committed by Henrik Brix Andersen
parent 073871bdeb
commit d9ff7eb0ed

View file

@ -3113,7 +3113,8 @@ uint8_t bt_gatt_check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr
* the error code Insufficient Encryption. * the error code Insufficient Encryption.
*/ */
if (mask & (BT_GATT_PERM_ENCRYPT_MASK | BT_GATT_PERM_AUTHEN_MASK)) { if (mask &
(BT_GATT_PERM_ENCRYPT_MASK | BT_GATT_PERM_AUTHEN_MASK | BT_GATT_PERM_LESC_MASK)) {
#if defined(CONFIG_BT_SMP) #if defined(CONFIG_BT_SMP)
if (!conn->encrypt) { if (!conn->encrypt) {
if (bt_conn_ltk_present(conn)) { if (bt_conn_ltk_present(conn)) {