Diff between 338f51e5ffbdcfd7394f6a0e54b49b1a0b0c6850 and fa17cf9b91e7cac5d28399974b020e529cc90f2b

Changed Files

File Additions Deletions Status
src/shared/gatt-db.c +5 -2 modified

Full Patch

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 47aae7f..780d640 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -29,6 +29,7 @@
 #include "src/shared/queue.h"
 #include "src/shared/timeout.h"
 #include "src/shared/gatt-db.h"
+#include "src/shared/att-types.h"
 
 #ifndef MAX
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
@@ -1457,8 +1458,10 @@ bool gatt_db_attribute_read(struct gatt_db_attribute *attrib, uint16_t offset,
 	}
 
 	/* Check boundary if value is stored in the db */
-	if (offset > attrib->value_len)
-		return false;
+	if (offset > attrib->value_len) {
+		func(attrib, BT_ATT_ERROR_INVALID_OFFSET, NULL, 0, user_data);
+		return true;
+	}
 
 	/* Guard against invalid access if offset equals to value length */
 	value = offset == attrib->value_len ? NULL : &attrib->value[offset];