[PATCH BlueZ] shared/gatt-client: Fix not detecting BT_ATT_SECURITY_AUTO

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

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

Using bt_gatt_security cannot detect if BT_ATT_SECURITY_AUTO is enabled
since it actually checks the current level when operating over L2CAP, so
instead use io_sec_level internal field to detect the security level in
which ATT is supposed to be operating.
---
 src/shared/att.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/shared/att.c b/src/shared/att.c
index 3a84783..7b20757 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -573,10 +573,11 @@ static bool change_security(struct bt_att *att, uint8_t ecode)
 {
 	int security;
 
-	security = bt_att_get_security(att);
-	if (security != BT_ATT_SECURITY_AUTO)
+	if (att->io_sec_level != BT_ATT_SECURITY_AUTO)
 		return false;
 
+	security = bt_att_get_security(att);
+
 	if (ecode == BT_ATT_ERROR_INSUFFICIENT_ENCRYPTION &&
 					security < BT_ATT_SECURITY_MEDIUM)
 		security = BT_ATT_SECURITY_MEDIUM;
@@ -979,7 +980,7 @@ struct bt_att *bt_att_new(int fd, bool ext_signed)
 
 	att->io_on_l2cap = is_io_l2cap_based(att->fd);
 	if (!att->io_on_l2cap)
-		att->io_sec_level = BT_SECURITY_LOW;
+		att->io_sec_level = BT_ATT_SECURITY_LOW;
 
 	return bt_att_ref(att);
 
-- 
2.5.0

--
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