Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp61164pxb; Fri, 5 Mar 2021 14:29:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEa3MlZ8FPJZZHx6AHJlclXSRWUs1FMigWMCGBpmFG2XHY9GpNEjjXHDoteovHIe2Y0aTj X-Received: by 2002:a17:906:c081:: with SMTP id f1mr4457024ejz.97.1614983349404; Fri, 05 Mar 2021 14:29:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614983349; cv=none; d=google.com; s=arc-20160816; b=VwQVrtnTFErWxdVQ4YxK0IKAx4ZNZhEqlCzwmRtZ1iE2vFPMccZdVcYHQ0XDabAx2D CjtIFl4FCGLyp5mRbzbTG1BE3IMBvwu4kL0IEknOlS9B2Z8K7ypqoySg1cbGCnZGomRi ufc0Et0BPB2lnLMrj4pLvDNGq+FTbTr/xt+YT9OP7AzmuhwlTBogoXOj1i6Zstld63qW 9ewI/sWUd7yB1105QmekiKQc+XG5BD0HgqLu5OLsoVcnR+SqLqHyzQi6xt6PnhHU/8w6 gdjPQOjxJZWCZ5d+RQ4QPCTWbfskMZPQh7gFXnt73HJc+1yLH+0N3FF9obQrfKJAkJTz AebQ== 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 :message-id:date:subject:to:from:dkim-signature; bh=GLSACR2rGLj4GMP/8Poeu6HCwTLgbb1l/hD8kBqfPT0=; b=iKyNW0B5VO2okrO4ThhlQaMCR2mtOABs76TDa0seRcDiZR3Xya9AQVq7mF3jNjttQj fpwGmab59ZMeWEV0p5lqN+LrJBIB1wxn13k1e2rZoMk1w8Y/hp2S4t1Tw1tpPM8FOa6S L+rKLlqPNKjpAo3dVgTUIOj2IHhsOk0/2Vu8aPboLck7DRkh5q8AU85ESKeYfeKan9wO I5inxVrqlsyvUgZ3sMxPtDm/8SKZ6o2n62zppOs8+mvAg3oWg4foXptf2lBEyGJo9XNY Jn9OH/rL2npxkP/YXRAo4QII2jzclpWp4d6wVy8F7QIrlmmKZU7DEOVKnV5T0VL6BcpI xG/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=g74B9Z58; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs1si2659341edb.433.2021.03.05.14.28.08; Fri, 05 Mar 2021 14:29:09 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=g74B9Z58; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbhCEWZz (ORCPT + 99 others); Fri, 5 Mar 2021 17:25:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbhCEWZr (ORCPT ); Fri, 5 Mar 2021 17:25:47 -0500 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AAF3C06175F for ; Fri, 5 Mar 2021 14:25:47 -0800 (PST) Received: by mail-pl1-x62b.google.com with SMTP id g20so2143125plo.2 for ; Fri, 05 Mar 2021 14:25:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=GLSACR2rGLj4GMP/8Poeu6HCwTLgbb1l/hD8kBqfPT0=; b=g74B9Z58w/NbMw7a6gl/r2a3TdKqOT5LEvff1DF7gS8N7RVoVIImEX0IXLaEOWrfck BKeVNMWVc0Ctx3JfbrzbfceVa28Zi4E0+smC5mAt22T2keemUC3Idw3cbdGe894rcU98 TT6Jn+ZeB6dxQUSwEspwANxoJFh+FePdsrV3m8YVTLWn2RbvE6Z4S/zeiQb6k2IGAODr NzLt27y/KXX2/mwT/LqXaFIsM3yiF/7Kl49Z8ojm7F/5Qe6xq+mc5Wuy2aJFUnVYRfP4 OpU6J33PM/SvQdSC4b2NBfD/AMTUVRGsvQgPGgtxrtjMotsLzjbeRUf0dDu4faMOofyp wwng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=GLSACR2rGLj4GMP/8Poeu6HCwTLgbb1l/hD8kBqfPT0=; b=At+4wltAGINMFpQERb/0ifY3XFeCAyGJoqDE7/KGOXdQj6rqwaJcUAuLyV1ceQHk7w 4eIPpZkiGmas/K0ItF0yVhE1UZN28FnlUoprInVfA+8L4PUDuHBHeYDmysvBk3EJsCr+ VQ95iI+F1WZmUiuPdLs1HKGJj/KI0VLtnUGJkM7ie8CKVj01yFXLk72HlnnvIrJDLbiG /6CBn2WDkyxEVF7g+Qiat2U6hJao4dFglI6gZwNPOsqbR4u77fhYsOw4z7gjiRRvjdxg AvrRqgYfzjxRSkYD9SuTtUrOROno17iKlj0e8VsaWTXppUgfEnWjZMPt3tX4M8MzgUuK Rt9g== X-Gm-Message-State: AOAM53371TDmiHzjbyjEkGLqBRn7ydSwdE0VGQB2eoRb4D2z/Fpe8HEF bK4Ig5jN9t2b86Rp3U/NM/Sg7KY3RtB3+g== X-Received: by 2002:a17:902:503:b029:e4:2ce1:f0c9 with SMTP id 3-20020a1709020503b02900e42ce1f0c9mr10334689plf.52.1614983146404; Fri, 05 Mar 2021 14:25:46 -0800 (PST) Received: from lvondent-mobl4.intel.com (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id gw20sm3106893pjb.3.2021.03.05.14.25.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Mar 2021 14:25:46 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ] gatt: Fix registering DIS without a valid source Date: Fri, 5 Mar 2021 14:25:44 -0800 Message-Id: <20210305222544.4005053-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz 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. Fixes https://github.com/bluez/bluez/issues/101 --- src/gatt-database.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gatt-database.c b/src/gatt-database.c index bd5864bcd..6c9e19ff3 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -1241,22 +1241,23 @@ 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; + /* Only register DIS if source has been set */ + 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); -- 2.29.2