[Bluez PATCH v1] plugins/admin: add uuid duplicate check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Yun-Hao Chung <howardchung@xxxxxxxxxxxx>

SetServiceAllowlist should ignore those duplicated UUIDs.

Reviewed-by: Miao-chen Chou <mcchou@xxxxxxxxxxxx>
---
Test steps:
1. set service allow list to ["1800", "1800", "180A"] via D-Bus
2. check service allow list is ["1800", "180A"]

 plugins/admin.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/plugins/admin.c b/plugins/admin.c
index 428a5528cc88..aea33cb71ac2 100644
--- a/plugins/admin.c
+++ b/plugins/admin.c
@@ -85,6 +85,14 @@ static void admin_policy_free(void *data)
 	g_free(admin_policy);
 }
 
+static bool uuid_match(const void *data, const void *match_data)
+{
+	const bt_uuid_t *uuid = data;
+	const bt_uuid_t *match_uuid = match_data;
+
+	return bt_uuid_cmp(uuid, match_uuid) == 0;
+}
+
 static struct queue *parse_allow_service_list(struct btd_adapter *adapter,
 							DBusMessage *msg)
 {
@@ -119,9 +127,15 @@ static struct queue *parse_allow_service_list(struct btd_adapter *adapter,
 			goto failed;
 		}
 
+		dbus_message_iter_next(&arr_iter);
+
+		if (queue_find(uuid_list, uuid_match, uuid)) {
+			g_free(uuid);
+			continue;
+		}
+
 		queue_push_head(uuid_list, uuid);
 
-		dbus_message_iter_next(&arr_iter);
 	} while (true);
 
 	return uuid_list;
-- 
2.32.0.605.g8dce9f2422-goog




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux