Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1409840ybz; Sat, 25 Apr 2020 18:40:51 -0700 (PDT) X-Google-Smtp-Source: APiQypLiHOBtzaBpAkmy6DWQTjFA5Yv8JpZ/sb2JmS+VYAOoqOt5DGl94ySpg1oZltG4EccA4mBx X-Received: by 2002:a17:906:7804:: with SMTP id u4mr14166393ejm.328.1587865251467; Sat, 25 Apr 2020 18:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587865251; cv=none; d=google.com; s=arc-20160816; b=J1IqHTCGBNcMcZhVsjDaXMfvNWNEA2TQyrqkPMHsLLIRPRlmjeiHJ3K046w48Tb+kn Sk8oXqiougx26sW6ncY9F1wTPRSIzY86Rvy+mwbJ3ZBl8Mvn+LxJVApBsyrOxX1//kpx oZ9j/pjR5s2GiwTDuxkcgPeJWNWarS4epdResQ+49NG14ThWSahXqWc/5L/9hG+1K6fp LBqUEaupbl1OYlrTlBohGiOuBnHAGE8IVnWWQlRkma9olmjzilXk6siIw76cP24fIYYH LZ7P1Hacf7yNbuhzzN16F3Rf4gwkfgL5yZtosRxTrRSP9o9h+BViX4VaPXWLWWBlQ1xo u0JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=sY9DuPp4YT1BeXakn3aLkKJz2YAQ2ryvln0omqrV7W8=; b=e1RfPc1SMWEOW3XbFeVNpCbSMq5jAI3+Obq7/jBpt1kGCPzV8i0q60rHIHOw5NkTpj I2mBNfRGTy28FKoZ7B26h6ZHtezKXonViMVSvqzfqonl2P2vdbe/u3Y+6Ow9rWrZvhq1 mbAxArWSoVHgYWGejv657EijCx02T95X0AQ4gQpI37a+ei5yae9n5Um33l5JZ41FvZcY mMpdNpV8evHhr4r2oyka149d37ck+nYTH9fYjgnsLCWQUiAhVXL07g07VArk2J+LTw8X Ygb23Luwro4BBIzqAFn/ywXYD7/1+97yRyuV4avZhN6+5E4R0CYYwRZ/awZ4IaXOCc/6 kxpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lechnology.com header.s=default header.b=Dv6UCnP8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ks2si6257135ejb.445.2020.04.25.18.40.06; Sat, 25 Apr 2020 18:40:51 -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=fail header.i=@lechnology.com header.s=default header.b=Dv6UCnP8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726087AbgDZBj5 (ORCPT + 99 others); Sat, 25 Apr 2020 21:39:57 -0400 Received: from vern.gendns.com ([98.142.107.122]:53036 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725931AbgDZBj4 (ORCPT ); Sat, 25 Apr 2020 21:39:56 -0400 X-Greylist: delayed 1200 seconds by postgrey-1.27 at vger.kernel.org; Sat, 25 Apr 2020 21:39:56 EDT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=sY9DuPp4YT1BeXakn3aLkKJz2YAQ2ryvln0omqrV7W8=; b=Dv6UCnP8fGvptSjzCNEiAgizao 8Uu2SClHFC8htqqpxY3IwTgPC6V32V/+zvrCZA7XJ0E4ZcUVUyEs38H3by1ePCwaQ/A3oadBZxN2T AAL3KX39wqDC5EYaMmlnuI9usYUffS5QiQMoST4ecWSjo8HX2JE/gyztFXqw/HoXpud/4iPjOaCgx 28JUwOK6WlGxMNvMMYXZu8S2ahAE0RpxUTMymw6c34DwMjMXY6iuh+FoMSTTgH4hY0XokKp2jOhDX jSKjtV+/IR5JK7fwrk76fvKnppPPClUWoRc/osLIEWshlAlICMGZTpF7gq8qzTAMQLXAvd4PuRtjR Oad3Kz2Q==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:46210 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1jSVxb-0004xU-Ec; Sat, 25 Apr 2020 21:19:55 -0400 From: David Lechner To: linux-bluetooth@vger.kernel.org Cc: David Lechner Subject: [PATCH BlueZ] src/gatt-client: always check properties in WriteValue Date: Sat, 25 Apr 2020 20:19:35 -0500 Message-Id: <20200426011935.32742-1-david@lechnology.com> X-Mailer: git-send-email 2.17.1 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This modifies the GATT client characteristic WriteValue D-Bus method to always check that the characteristic supports the requested type of write by checking for the corresponding property before attempting to write. Before this change, if the "type" option was used and it was set to "reliable" or "request", then BlueZ would attempt the write even if the characteristic does not support that write type. On the other hand, if "type" was set to "command" or was not specified, the method would return a org.bluez.Error.NotSupported error without attempting to write. After this change, the WriteValue method will consistently return org.bluez.Error.NotSupported if the corresponding property flag is not set for all types of writes. --- src/gatt-client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gatt-client.c b/src/gatt-client.c index a9bfc2802..0bfcfa692 100644 --- a/src/gatt-client.c +++ b/src/gatt-client.c @@ -1016,8 +1016,8 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn, * - If value is larger than MTU - 3: long-write * * "write-without-response" property set -> write command. */ - if ((!type && (chrc->ext_props & BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE)) - || (type && !strcasecmp(type, "reliable"))) { + if ((!type || (type && !strcasecmp(type, "reliable"))) && + chrc->ext_props & BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE) { supported = true; chrc->write_op = start_long_write(msg, chrc->value_handle, gatt, true, value, value_len, offset, @@ -1026,8 +1026,8 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn, return NULL; } - if ((!type && chrc->props & BT_GATT_CHRC_PROP_WRITE) || - (type && !strcasecmp(type, "request"))) { + if ((!type || (type && !strcasecmp(type, "request"))) && + chrc->props & BT_GATT_CHRC_PROP_WRITE) { uint16_t mtu; supported = true; -- 2.17.1