2014-04-17 14:19:45

by Claudio Takahasi

[permalink] [raw]
Subject: [PATCH BlueZ v0] gatt: Fix not replying for write requests

Attributes should not be unregistered dynamically unless the service
implementation calls UnregisterService() or leave the system bus.
Implementations may accidentally (or maliciously) unregister a GATT
object (characteristic or descriptor) belonging to a service hierarchy.
gdbus automatically tracks InterfacesRemoved() signal, and destroys the
GDBusProxy associated with the removed interfaces. Subsequent calls of
g_dbus_proxy_set_property_array() returns FALSE, and it needs to be
handled properly since the GDBusProxy result callback will not be called.
---
src/gatt-dbus.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/gatt-dbus.c b/src/gatt-dbus.c
index 26437e7..c22e8af 100644
--- a/src/gatt-dbus.c
+++ b/src/gatt-dbus.c
@@ -332,9 +332,13 @@ static void proxy_write_cb(struct btd_attribute *attr,
wdata->result_cb = result;
wdata->user_data = user_data;

- g_dbus_proxy_set_property_array(proxy, "Value", DBUS_TYPE_BYTE,
- value, len, proxy_write_reply,
- wdata, g_free);
+ if (!g_dbus_proxy_set_property_array(proxy, "Value",
+ DBUS_TYPE_BYTE, value, len,
+ proxy_write_reply,
+ wdata, g_free)) {
+ g_free(wdata);
+ result(-ENOENT, user_data);
+ }
} else {
/*
* Caller is not interested in the Set method call result.
--
1.8.3.1



2014-04-22 11:34:30

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH BlueZ v0] gatt: Fix not replying for write requests

Hi Claudio,

On Thu, Apr 17, 2014, Claudio Takahasi wrote:
> Attributes should not be unregistered dynamically unless the service
> implementation calls UnregisterService() or leave the system bus.
> Implementations may accidentally (or maliciously) unregister a GATT
> object (characteristic or descriptor) belonging to a service hierarchy.
> gdbus automatically tracks InterfacesRemoved() signal, and destroys the
> GDBusProxy associated with the removed interfaces. Subsequent calls of
> g_dbus_proxy_set_property_array() returns FALSE, and it needs to be
> handled properly since the GDBusProxy result callback will not be called.
> ---
> src/gatt-dbus.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)

Applied. Thanks.

Johan