From bc6facb0cfcfa3098b57f93919b69e7ffb204f04 Mon Sep 17 00:00:00 2001 From: Grzegorz Kolodziejczyk Date: Tue, 20 Mar 2018 15:05:18 +0100 Subject: [PATCH] client: Update read callbacks with invalid offset error handlers This patch adds invalid offset handlers to read callbacks of attributes. --- client/gatt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/gatt.c b/client/gatt.c index 7a6035ac1..3fa490b1a 100644 --- a/client/gatt.c +++ b/client/gatt.c @@ -1473,6 +1473,10 @@ static DBusMessage *chrc_read_value(DBusConnection *conn, DBusMessage *msg, parse_offset(&iter, &offset); + if (offset > chrc->value_len) + return g_dbus_create_error(msg, "org.bluez.Error.InvalidOffset", + NULL); + return read_value(msg, &chrc->value[offset], chrc->value_len - offset); } @@ -1831,6 +1835,10 @@ static DBusMessage *desc_read_value(DBusConnection *conn, DBusMessage *msg, parse_offset(&iter, &offset); + if (offset > desc->value_len) + return g_dbus_create_error(msg, "org.bluez.Error.InvalidOffset", + NULL); + return read_value(msg, &desc->value[offset], desc->value_len - offset); } -- 2.47.3