Bluetooth: GATT: Fix segfault discover descriptors all UUIDs
Handle optional argument UUID in bt_gatt_discover with type DISCOVER_DESCRIPTOR, bt_uuid_cmp doesn't check for NULL pointer. On system with MMU (nrf52_bsim) this can result in segfault. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
600c1d6fa7
commit
3bddc20f87
1 changed files with 5 additions and 4 deletions
|
@ -2587,10 +2587,11 @@ int bt_gatt_discover(struct bt_conn *conn,
|
|||
return gatt_read_type(conn, params);
|
||||
case BT_GATT_DISCOVER_DESCRIPTOR:
|
||||
/* Only descriptors can be filtered */
|
||||
if (!bt_uuid_cmp(params->uuid, BT_UUID_GATT_PRIMARY) ||
|
||||
!bt_uuid_cmp(params->uuid, BT_UUID_GATT_SECONDARY) ||
|
||||
!bt_uuid_cmp(params->uuid, BT_UUID_GATT_INCLUDE) ||
|
||||
!bt_uuid_cmp(params->uuid, BT_UUID_GATT_CHRC)) {
|
||||
if (params->uuid &&
|
||||
(!bt_uuid_cmp(params->uuid, BT_UUID_GATT_PRIMARY) ||
|
||||
!bt_uuid_cmp(params->uuid, BT_UUID_GATT_SECONDARY) ||
|
||||
!bt_uuid_cmp(params->uuid, BT_UUID_GATT_INCLUDE) ||
|
||||
!bt_uuid_cmp(params->uuid, BT_UUID_GATT_CHRC))) {
|
||||
return -EINVAL;
|
||||
}
|
||||
/* Fallthrough. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue