Diff between d3fcc77f99da755bb364c491f71638358bdd5f09 and 1e22fd9adbb3283f1a081b94248e97b662256d54

Changed Files

File Additions Deletions Status
attrib/gatt.c +5 -3 modified

Full Patch

diff --git a/attrib/gatt.c b/attrib/gatt.c
index b496dd1..3cedae9 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -1076,10 +1076,12 @@ static void desc_discovered_cb(guint8 status, const guint8 *ipdu,
 	att_data_list_free(list);
 
 	/*
-	 * If last handle is lower from previous start handle then it is smth
-	 * wrong. Let's stop search, otherwise we might enter infinite loop.
+	 * If last handle is lower from previous start handle or if iterating
+	 * to the next handle from the last possible offset would overflow, then
+	 * something is wrong. Let's stop search, otherwise we might enter
+	 * infinite loop.
 	 */
-	if (last < dd->start) {
+	if (last < dd->start || last == G_MAXUINT16) {
 		err = ATT_ECODE_UNLIKELY;
 		goto done;
 	}