client: Update read callbacks with invalid offset error handlers 45/204945/1
authorGrzegorz Kolodziejczyk <grzegorz.kolodziejczyk@codecoup.pl>
Tue, 20 Mar 2018 14:05:18 +0000 (15:05 +0100)
committerAmit Purwar <amit.purwar@samsung.com>
Fri, 26 Apr 2019 10:52:14 +0000 (16:22 +0530)
This patch adds invalid offset handlers to read callbacks of attributes.

Change-Id: I7c9184e0f0caf0e43c7b37eeaa40a6a12a1fd883
Signed-off-by: Amit Purwar <amit.purwar@samsung.com>
client/gatt.c

index 7a6035a..3fa490b 100755 (executable)
@@ -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);
 }