summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2021-03-05 14:23:44 -0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2021-03-05 14:59:29 -0800
commite6b69a5d4ef795b618ffeebe9dc87cd0c35cb4f9 (patch)
treefd98c3943a4f1c6f97f1b24fa751a945eafcb231
parentb3f7623fbab34ea73ab9a9c067572a5764fa07bd (diff)
downloadbluez-e6b69a5d4ef795b618ffeebe9dc87cd0c35cb4f9.tar.gz
gatt: Fix registering DIS without a valid source
If source has not been set don't register DIS as it would not contain any useful information and by doing this it actually allows systems to register their own DIS instance.
-rw-r--r--src/gatt-database.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/gatt-database.c b/src/gatt-database.c
index bd5864bcd..be6dfb265 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -1241,22 +1241,22 @@ static void device_info_read_pnp_id_cb(struct gatt_db_attribute *attrib,
static void populate_devinfo_service(struct btd_gatt_database *database)
{
struct gatt_db_attribute *service;
+ struct gatt_db_attribute *attrib;
bt_uuid_t uuid;
+ if (!btd_opts.did_source)
+ return;
+
bt_uuid16_create(&uuid, UUID_DIS);
service = gatt_db_add_service(database->db, &uuid, true, 3);
- if (btd_opts.did_source > 0) {
- struct gatt_db_attribute *attrib;
-
- bt_uuid16_create(&uuid, GATT_CHARAC_PNP_ID);
- attrib = gatt_db_service_add_characteristic(service, &uuid,
+ bt_uuid16_create(&uuid, GATT_CHARAC_PNP_ID);
+ attrib = gatt_db_service_add_characteristic(service, &uuid,
BT_ATT_PERM_READ,
BT_GATT_CHRC_PROP_READ,
device_info_read_pnp_id_cb,
NULL, database);
- gatt_db_attribute_set_fixed_length(attrib, 7);
- }
+ gatt_db_attribute_set_fixed_length(attrib, 7);
gatt_db_service_set_active(service, true);
@@ -1267,10 +1267,7 @@ static void register_core_services(struct btd_gatt_database *database)
{
populate_gap_service(database);
populate_gatt_service(database);
-
- if (btd_opts.did_source > 0)
- populate_devinfo_service(database);
-
+ populate_devinfo_service(database);
}
static void conf_cb(void *user_data)