tester: bluetooth: gatt: fix null pointer case CASE failed

GATT/SR/GAD/BV-03-C will read attr value, but we parse NULL
from `attr->read` which point to `attr_read` function.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This commit is contained in:
Lingao Meng 2021-08-05 20:57:22 +08:00 committed by Carles Cufí
commit ce40fa434f

View file

@ -304,7 +304,7 @@ static ssize_t read_value(struct bt_conn *conn, const struct bt_gatt_attr *attr,
return BT_GATT_ERR(BT_ATT_ERR_AUTHORIZATION);
}
if ((attr->perm & GATT_PERM_ENC_READ_MASK) &&
if ((attr->perm & GATT_PERM_ENC_READ_MASK) && (conn != NULL) &&
(value->enc_key_size > bt_conn_enc_key_size(conn))) {
return BT_GATT_ERR(BT_ATT_ERR_ENCRYPTION_KEY_SIZE);
}