All of lore.kernel.org
 help / color / mirror / Atom feed
From: Howard Chung <howardchung@google.com>
To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com
Cc: Yun-Hao Chung <howardchung@chromium.org>,
	Miao-chen Chou <mcchou@chromium.org>
Subject: [Bluez PATCH v1] plugins/admin: add uuid duplicate check
Date: Wed, 11 Aug 2021 15:17:57 +0800	[thread overview]
Message-ID: <20210811151742.Bluez.v1.1.I3c1703ddae63da383b15e001bc965dadb4bd00b8@changeid> (raw)

From: Yun-Hao Chung <howardchung@chromium.org>

SetServiceAllowlist should ignore those duplicated UUIDs.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
---
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


             reply	other threads:[~2021-08-11  7:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11  7:17 Howard Chung [this message]
2021-08-11  7:35 ` [Bluez,v1] plugins/admin: add uuid duplicate check bluez.test.bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210811151742.Bluez.v1.1.I3c1703ddae63da383b15e001bc965dadb4bd00b8@changeid \
    --to=howardchung@google.com \
    --cc=howardchung@chromium.org \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=mcchou@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.