[PATCH] shared/gatt: Check if handles counter is not wrapped

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make sure that handles are fitting in UINT16_MAX range before adding
service to database.
---
 src/shared/gatt-db.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c
index 6a15a4c..ebfd586 100644
--- a/src/shared/gatt-db.c
+++ b/src/shared/gatt-db.c
@@ -162,7 +162,7 @@ uint16_t gatt_db_add_service(struct gatt_db *db, const bt_uuid_t *uuid,
 	uint8_t value[16];
 	uint16_t len;
 
-	if (num_handles < 1)
+	if (num_handles < 1 || (num_handles + db->next_handle) > UINT16_MAX)
 		return 0;
 
 	service = new0(struct gatt_db_service, 1);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux