From 5bbefdcc9d2254b5a193c9361a44257d69e11246 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 28 Mar 2025 10:34:24 -0400 Subject: [PATCH] shared/att: Fix not always setting security for BT_ATT_LOCAL Channels created with BT_ATT_LOCAL (socket pair) shall not be restricted from downgrading the security level since its default security level is BT_ATT_SECURITY_LOW and it may need to be switched to BT_ATT_SECURITY_AUTO. --- src/shared/att.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/shared/att.c b/src/shared/att.c index 8657cb642..14d346ca7 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -727,6 +727,11 @@ static bool bt_att_chan_set_security(struct bt_att_chan *chan, int level) { struct bt_security sec; + if (chan->type == BT_ATT_LOCAL) { + chan->sec_level = level; + return true; + } + /* Check if security level has already been set, if the security level * is higher it shall satisfy the request since we never want to * downgrade security. @@ -734,11 +739,6 @@ static bool bt_att_chan_set_security(struct bt_att_chan *chan, int level) if (level <= bt_att_chan_get_security(chan)) return true; - if (chan->type == BT_ATT_LOCAL) { - chan->sec_level = level; - return true; - } - memset(&sec, 0, sizeof(sec)); sec.level = level; -- 2.47.3