Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4221295pxt; Wed, 11 Aug 2021 00:19:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNX6U8gXA95riaLo+F94O4sicUGDw7tIim4TeKM4XPkTedWEoPuAJcfWa0warvEsucDE1D X-Received: by 2002:a92:8707:: with SMTP id m7mr19929ild.177.1628666372696; Wed, 11 Aug 2021 00:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628666372; cv=none; d=google.com; s=arc-20160816; b=tprD2Tv50jNPmTIM/MUSANYruZ3f7QY6k1YQ88HlsWW8xUkojeRJv9em68T2BCwMCg 1YPKUZYZtjESzKxoLH4ERrjc62/0wHtFjLscVbRrfGKqlyhmhrcG/oTQG6djk/h7aBb+ gBkMLYmKznta7JCC1HBRWC0gI9KXBuriJo2LpdEAXw6AkE5GyxuJ0LwjFBcEmAwDcK3P 67t7k9xjldbBZnIfEdzXP3lzwKS4lHL0VIU1BoVmvLBKjha+i49LjXyXzPV78JtiobbF 3Jtgr0h597eRmatKKOt/DzRuk5LW5biD1rUKoK36d9Gxb1fbUYeUzR0kVTtZv5gutMpf 6QeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=V0F2q6DWz68y9EMObI0aq5egV2DxRbNMTPAOBAB1rDo=; b=vgBqg4yotbsZXB12sSVSubh2dKd3L/9YVJ7/tw59zp5Y17lbqmOfVR62+u3mrW1O1a +i2BV7cOWfRmJhTBxu3yJ4vHzxkv4/2Z6nmIA8SBpG0XhZu/6nvZGx0TYq7POznqTpxE rLBF/h3cKJ5OXHK7RqcimyklMOxJy/r3QXhzy4wkRsoazQMwqgMMv/CiRlnwxW/Jtb34 XONxMK49EF04U1HAC7L4kReELVSG+Ex40oi/gngS5fOZoqa5c8wcb80vjLuPmpwgf0P3 YSM/uN/+EjS4rBr0Osn+OiAFZ25FsYLxPqhohCv+b5miKyiVVaXmH2WE+UKEMQvnhkQ/ fQHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hUpx6WAS; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z2si26823994ilh.121.2021.08.11.00.19.19; Wed, 11 Aug 2021 00:19:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hUpx6WAS; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235294AbhHKHTF (ORCPT + 99 others); Wed, 11 Aug 2021 03:19:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235135AbhHKHTE (ORCPT ); Wed, 11 Aug 2021 03:19:04 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1274C061765 for ; Wed, 11 Aug 2021 00:18:41 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id h4-20020a2597440000b0290593ddcb3a3aso1440038ybo.5 for ; Wed, 11 Aug 2021 00:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=V0F2q6DWz68y9EMObI0aq5egV2DxRbNMTPAOBAB1rDo=; b=hUpx6WAStVkEDkhWBZxUet5OoZ0b0C1e7Fzu7vKARtVcjnlOC+EOyV0Cbht2VpTOmG OA1Y9TK9m0HWSlXaAsCMVOFpjAuzDIf7MWLjDmit44qKLw+TJ+JYnS5Yp/9d3uY6MTwM g1XHhltWlu8ZYbo88NYJsL/0Ofbt+OqdeLn8lvW4LbxHr4ZGhg6GWgLua3sUs+RlXjoi KIvpFVfUOZVGj5SKVhDUKqqGX2fACX3/ABTBoLDdcdhZRg0PhyzKVAhNbOwdtYl56xqw z2SWExG1BSwIU02YoyziN59z4dhtgoYL+ZCzoep3UiDzGlaTxU7ieZUASB4YGPRyLoO6 bfkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=V0F2q6DWz68y9EMObI0aq5egV2DxRbNMTPAOBAB1rDo=; b=Rk9XuXoqKDs1VpV+kFNzUHy4tESWpfWADWOE+TtqOabKNLkhFKTcZFGy/aQZLCUdWN YxORHIyrhSJSs9CpNDcCLcvzdY84FEk5wb5FhWn1BKEr7Wz+DyNj3T08nhsXkEYgKMKp 8Nje6CTDrHgHHi4/SqyqmDObleYxWL7bf14dOXzzCmfrruIDZ0hWDCgFYb/bHtJMvSKA cFO0inB/k5Pg51r1027TIt6zkUMl0nPK7IMDcOkACtHz9WYtR7irSns9thZb2H+Xu1JN Lt9VbLTcsD5m7RxYqHg54KN3MTxKSPHo1NfBsrwYuRAX3eSYFRA6G7KF/3ao18GIaHRO 6dYQ== X-Gm-Message-State: AOAM532jbIlAaj68Du8m5PYKsHfohrXEMKPinS4EdksTrv6mIBePjUUl abgsqih7PZ0gi6jqYtMHaoUjXtcrexGz6hudbrtwf+z3f5LqMkrdZX9+yr5DrXzSRNy8Jr3JwY3 qINItqFewrA4II967Jxm0BeZD3wtxpCY3ytAVXJL0bra/4PAuG7NwsX4dJWUCub6eGUOlP523Yj G2v4fn+4fgMSk= X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:42fe:de1a:97f8:9006]) (user=howardchung job=sendgmr) by 2002:a25:2496:: with SMTP id k144mr12045177ybk.366.1628666320938; Wed, 11 Aug 2021 00:18:40 -0700 (PDT) Date: Wed, 11 Aug 2021 15:17:57 +0800 Message-Id: <20210811151742.Bluez.v1.1.I3c1703ddae63da383b15e001bc965dadb4bd00b8@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.605.g8dce9f2422-goog Subject: [Bluez PATCH v1] plugins/admin: add uuid duplicate check From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Cc: Yun-Hao Chung , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Yun-Hao Chung SetServiceAllowlist should ignore those duplicated UUIDs. Reviewed-by: Miao-chen Chou --- 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