* [PATCH BlueZ] client: Update write callbacks with invalid offset error handlers
@ 2020-05-05 8:29 Mariusz Skamra
2020-05-11 13:29 ` Szymon Janc
0 siblings, 1 reply; 2+ messages in thread
From: Mariusz Skamra @ 2020-05-05 8:29 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Mariusz Skamra
This patch adds invalid offset handlers to write callbacks of attributes.
---
client/gatt.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/client/gatt.c b/client/gatt.c
index 416eda953..5713f8343 100644
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -2141,6 +2141,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);
@@ -2272,6 +2278,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);
@@ -2683,6 +2694,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,
--
2.25.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH BlueZ] client: Update write callbacks with invalid offset error handlers
2020-05-05 8:29 [PATCH BlueZ] client: Update write callbacks with invalid offset error handlers Mariusz Skamra
@ 2020-05-11 13:29 ` Szymon Janc
0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2020-05-11 13:29 UTC (permalink / raw)
To: linux-bluetooth, Mariusz Skamra; +Cc: Mariusz Skamra
Hi Mariusz,
On Tuesday, 5 May 2020 10:29:01 CEST Mariusz Skamra wrote:
> This patch adds invalid offset handlers to write callbacks of attributes.
> ---
> client/gatt.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/client/gatt.c b/client/gatt.c
> index 416eda953..5713f8343 100644
> --- a/client/gatt.c
> +++ b/client/gatt.c
> @@ -2141,6 +2141,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);
> @@ -2272,6 +2278,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);
> @@ -2683,6 +2694,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,
Applied, thanks.
--
pozdrawiam
Szymon Janc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-11 13:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 8:29 [PATCH BlueZ] client: Update write callbacks with invalid offset error handlers Mariusz Skamra
2020-05-11 13:29 ` Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).