Diff between 492814f0ee946a4e399a05414006b1a485eecd71 and 4ca0a7861b474e4d0f7f5ba7e1bbfc496dab7132

Changed Files

File Additions Deletions Status
android/bluetooth.c +4 -3 modified
android/bluetooth.h +2 -1 modified
android/gatt.c +2 -2 modified

Full Patch

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 3016ea4..827e205 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -4145,7 +4145,8 @@ static void store_sign_counter(struct device *dev, enum bt_csrk_type type)
 	g_key_file_free(key_file);
 }
 
-void bt_update_sign_counter(const bdaddr_t *addr, enum bt_csrk_type type)
+void bt_update_sign_counter(const bdaddr_t *addr, enum bt_csrk_type type,
+								uint32_t val)
 {
 	struct device *dev;
 
@@ -4154,9 +4155,9 @@ void bt_update_sign_counter(const bdaddr_t *addr, enum bt_csrk_type type)
 		return;
 
 	if (type == LOCAL_CSRK)
-		dev->local_sign_cnt++;
+		dev->local_sign_cnt = val;
 	else
-		dev->remote_sign_cnt++;
+		dev->remote_sign_cnt = val;
 
 	store_sign_counter(dev, type);
 }
diff --git a/android/bluetooth.h b/android/bluetooth.h
index fffb3cc..8970559 100644
--- a/android/bluetooth.h
+++ b/android/bluetooth.h
@@ -72,7 +72,8 @@ bool bt_read_device_rssi(const bdaddr_t *addr, bt_read_device_rssi_done cb,
 bool bt_get_csrk(const bdaddr_t *addr, enum bt_csrk_type type,
 					uint8_t key[16], uint32_t *sign_cnt);
 
-void bt_update_sign_counter(const bdaddr_t *addr, enum bt_csrk_type type);
+void bt_update_sign_counter(const bdaddr_t *addr, enum bt_csrk_type type,
+								uint32_t val);
 
 void bt_store_gatt_ccc(const bdaddr_t *addr, uint16_t value);
 
diff --git a/android/gatt.c b/android/gatt.c
index ad20a71..e1d7df2 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -3169,7 +3169,7 @@ static guint signed_write_cmd(struct gatt_device *dev, uint16_t handle,
 		return 0;
 	}
 
-	bt_update_sign_counter(&dev->bdaddr, LOCAL_CSRK);
+	bt_update_sign_counter(&dev->bdaddr, LOCAL_CSRK, sign_cnt++);
 
 	return res;
 }
@@ -5941,7 +5941,7 @@ static void write_signed_cmd_request(const uint8_t *cmd, uint16_t cmd_len,
 			return;
 		}
 		/* Signature OK, proceed with write */
-		bt_update_sign_counter(&dev->bdaddr, REMOTE_CSRK);
+		bt_update_sign_counter(&dev->bdaddr, REMOTE_CSRK, sign_cnt++);
 		gatt_db_write(gatt_db, handle, 0, value, vlen, cmd[0],
 								&dev->bdaddr);
 	}