Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp9355129rwr; Thu, 11 May 2023 13:45:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ79mHc5OEZVeBFPU4vuAQ5PR9DHY3dhoev+nskAW5eYoutES9TIP6UNqIHc/FXg6H7tA508 X-Received: by 2002:a05:6a00:248d:b0:63a:8f4c:8be1 with SMTP id c13-20020a056a00248d00b0063a8f4c8be1mr33401737pfv.10.1683837932808; Thu, 11 May 2023 13:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683837932; cv=none; d=google.com; s=arc-20160816; b=0k9FcM/8gsm7RxOclPC9cxgv+rTkUlIUHiGlzeKdpO+g0zoIz4Dvp6SXRo3jXcX1WL rZDAkaYYZpi4KKTwdBfodfmeZeFV/FyjwELBP3R0ozauD2a0/DTfjiHAkOM4LHiAxGgj 15pCWhlAGQWgBQuKK1Ngg6aoz4B/UIrikK3f6eqgXXVuxm+/mfcFM9wBv//Bx9pnygar t+lZISxCa9uNr1OoS5mN8700aEzdPgtZrSuv2NrQUUAvMPe83gAhqdQvgJsH7VEJ93c2 v1R092KOsOKVDGKOlpEQsTsmZCatKZT/FCYqV8Cs1IXIbsxIkI6Gk1gXgxVK3pB0JL7Z A45w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=emvuPNhNRveuiLJ+SN5oWzjXH32hbgFtDeH+ADZ9nbM=; b=JTZBeeqZ2MJ858twdco3tCzXj/Ar1zhWWwZvAw47LWlxQQBNYbD0gWq+RxZ7icwfpp lc2KOOPUIEiFsB7zgB53scNvKJZ8xACi4zTwbfrC3uBRjN0c64a2HVtKucwLswJ0xFDU nLlS+SX1Cv+asnPlISzZD/8iNWqVpw6scRFT/fW6hmMZ9oZjMuqPnznPTTqFjH2UwhUG FVoJrONwO08lQE7BydsqJsxradYsFAFjNS4d/MdlWikhp42k3Q4ml54+AwnnN+joqNlU XAoT/Xu9kKnQFwKfq2Pf64ZtSXjczZJvO0JO04Ug69b2vDR5GVznvOeUdLG989QkTq4E wRIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=VQTm0faf; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f29-20020a63381d000000b005289dd5ba0bsi7705163pga.410.2023.05.11.13.45.09; Thu, 11 May 2023 13:45:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=VQTm0faf; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239369AbjEKU2i (ORCPT + 99 others); Thu, 11 May 2023 16:28:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239392AbjEKU2f (ORCPT ); Thu, 11 May 2023 16:28:35 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88C59A246 for ; Thu, 11 May 2023 13:28:30 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-6436dfa15b3so6106423b3a.1 for ; Thu, 11 May 2023 13:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683836909; x=1686428909; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=emvuPNhNRveuiLJ+SN5oWzjXH32hbgFtDeH+ADZ9nbM=; b=VQTm0fafHXhE5RGThm1phrZgFgqLu5OtWz3j3P/LGR+fPV8Ugf8/DE0zZTHQfB2eVy NkTFQYOtlFear8r97gqXxX1rxa03KFsqpOvAFTzpwbZRJfYL0MyIxByfZUe9azLfEV4a ZIg6MlTSnkrvcxWI+AzebqBphe0EKqBXGaKcsEgTh7nruaLQnN4cyjKTUyw+xHGWZ3n3 uDlSahS9vs+FF5lzO/qlOeCU2IvFUiEuaWTFSx/Biyl4yDCrwCOjcBSQYyi36TNQqJSi 42AchNYIi2M5AAdCXSDQmPvqWtNbXutcO+J4HZDx0RkjGFN37N+Tfud3+/jmFLNgY9E8 ZS6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683836909; x=1686428909; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=emvuPNhNRveuiLJ+SN5oWzjXH32hbgFtDeH+ADZ9nbM=; b=AXFGNENsNuvbF3TOk+lT7bRd+rSX2lFdG+ri9xZKySJ9jlBQY0mMSNksDOa3gBcNUr TdiII+BESpx3VHfhuGlVBjZV3MRmzDJ4u46ielKk9evrkkQ71PvAZvRHxJgglX3zG163 69YQZXsECNTyEW7M82Rcsdpx9v5G+aAxfmpyWIru1OX/2wHnBhJ6Sp0Bdgosn2NdPbd0 hFwQF2EJmDr9r722HU97DZgBWbJD5zjWiLGbolQ+EicTC7t46DmR0ux6tRgqH7QgQf+W q6tZz2GFXZERu4uxrxef4SsVUZVbrF6f8x2lM4ghddoJxYpcmTF+FSb5a2LSPAES/u1C Angw== X-Gm-Message-State: AC+VfDzmJ9RBR48dsLi7y6WEfk+dGXh5YV4QjGD0i7AmfoKVchK0f2VU fnUkAZqSLDrc0AUcZHHWtB95OK6fuT8= X-Received: by 2002:a05:6a20:9193:b0:ec:7c4f:ed7a with SMTP id v19-20020a056a20919300b000ec7c4fed7amr28748433pzd.34.1683836909246; Thu, 11 May 2023 13:28:29 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id s24-20020aa78298000000b0062a7462d398sm5864529pfm.170.2023.05.11.13.28.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 13:28:27 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] client/player: Fix not checking for SupportedUUIDs Date: Thu, 11 May 2023 13:28:25 -0700 Message-Id: <20230511202825.3983806-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230511202825.3983806-1-luiz.dentz@gmail.com> References: <20230511202825.3983806-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz When registering an endpoint it should always check for SupportedUUIDs. --- client/player.c | 66 +++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/client/player.c b/client/player.c index 091d7005f42a..46eab32a40a0 100644 --- a/client/player.c +++ b/client/player.c @@ -2190,9 +2190,32 @@ static void register_endpoint_reply(DBusMessage *message, void *user_data) return bt_shell_noninteractive_quit(EXIT_SUCCESS); } +static bool media_supports_uuid(GDBusProxy *proxy, const char *uuid) +{ + DBusMessageIter iter, array; + + if (!g_dbus_proxy_get_property(proxy, "SupportedUUIDs", &iter)) + return false; + + dbus_message_iter_recurse(&iter, &array); + while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING) { + const char *support_uuid; + + dbus_message_iter_get_basic(&array, &support_uuid); + + if (!strcasecmp(uuid, support_uuid)) + return true; + + dbus_message_iter_next(&array); + } + + return false; +} + static void endpoint_register(struct endpoint *ep) { GList *l; + int registered = 0; if (!g_dbus_register_interface(dbus_conn, ep->path, BLUEZ_MEDIA_ENDPOINT_INTERFACE, @@ -2203,6 +2226,9 @@ static void endpoint_register(struct endpoint *ep) } for (l = medias; l; l = g_list_next(l)) { + if (!media_supports_uuid(l->data, ep->uuid)) + continue; + if (!g_dbus_proxy_method_call(l->data, "RegisterEndpoint", register_endpoint_setup, register_endpoint_reply, @@ -2211,8 +2237,13 @@ static void endpoint_register(struct endpoint *ep) BLUEZ_MEDIA_ENDPOINT_INTERFACE); goto fail; } + + registered++; } + if (!registered) + goto fail; + return; fail: @@ -3015,33 +3046,20 @@ static struct endpoint *endpoint_new(const struct capabilities *cap) static void register_endpoints(GDBusProxy *proxy) { struct endpoint *ep; - DBusMessageIter iter, array; + size_t i; - if (!g_dbus_proxy_get_property(proxy, "SupportedUUIDs", &iter)) - return; + for (i = 0; i < ARRAY_SIZE(caps); i++) { + const struct capabilities *cap = &caps[i]; - dbus_message_iter_recurse(&iter, &array); - while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING) { - const char *uuid; - size_t i; + if (!media_supports_uuid(proxy, cap->uuid)) + continue; - dbus_message_iter_get_basic(&array, &uuid); - - for (i = 0; i < ARRAY_SIZE(caps); i++) { - const struct capabilities *cap = &caps[i]; - - if (strcasecmp(cap->uuid, uuid)) - continue; - - ep = endpoint_new(cap); - ep->max_transports = UINT8_MAX; - ep->auto_accept = true; - ep->cig = BT_ISO_QOS_CIG_UNSET; - ep->cis = BT_ISO_QOS_CIS_UNSET; - endpoint_register(ep); - } - - dbus_message_iter_next(&array); + ep = endpoint_new(cap); + ep->max_transports = UINT8_MAX; + ep->auto_accept = true; + ep->cig = BT_ISO_QOS_CIG_UNSET; + ep->cis = BT_ISO_QOS_CIS_UNSET; + endpoint_register(ep); } } -- 2.40.0