summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorMariusz Skamra <mariusz.skamra@codecoup.pl>2020-05-05 10:29:01 +0200
committerSzymon Janc <szymon.janc@codecoup.pl>2020-05-11 15:26:55 +0200
commit236fb26ff4594f0239035d12b759909ae094c9a2 (patch)
treeca53e6391c789b0e084365e841cc4f07f84749cd /client
parent1c2271575d955193ca2d77acdad0546c1106c9da (diff)
downloadbluez-236fb26ff4594f0239035d12b759909ae094c9a2.tar.gz
client: Update write callbacks with invalid offset error handlers
This patch adds invalid offset handlers to write callbacks of attributes.
Diffstat (limited to 'client')
-rw-r--r--client/gatt.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/client/gatt.c b/client/gatt.c
index 9d35b54fa..e5bab6dd0 100644
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -2144,6 +2144,12 @@ static void authorize_write_response(const char *input, void *user_data)
goto error;
}
+ if (aad->offset > chrc->value_len) {
+ err = "org.bluez.Error.InvalidOffset";
+
+ goto error;
+ }
+
/* Authorization check of prepare writes */
if (prep_authorize) {
reply = g_dbus_create_reply(pending_message, DBUS_TYPE_INVALID);
@@ -2275,6 +2281,11 @@ static DBusMessage *chrc_write_value(DBusConnection *conn, DBusMessage *msg,
return NULL;
}
+ if (offset > chrc->value_len)
+ return g_dbus_create_error(msg,
+ "org.bluez.Error.InvalidOffset", NULL);
+
+
/* Authorization check of prepare writes */
if (prep_authorize)
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
@@ -2686,6 +2697,10 @@ static DBusMessage *desc_write_value(DBusConnection *conn, DBusMessage *msg,
return g_dbus_create_error(msg,
"org.bluez.Error.InvalidArguments", NULL);
+ if (offset > desc->value_len)
+ return g_dbus_create_error(msg,
+ "org.bluez.Error.InvalidOffset", NULL);
+
if (write_value(&desc->value_len, &desc->value, value,
value_len, offset, desc->max_val_len))
return g_dbus_create_error(msg,