From 436d089a6acd5cc4575751e10e819cf892419e5a Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Fri, 23 Jun 2023 15:08:14 +0200 Subject: [PATCH] l2cap: send ecbm pending if authentication possible --- src/l2cap.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/l2cap.c b/src/l2cap.c index 2698e453d..8fbff75dc 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -3929,10 +3929,18 @@ static int l2cap_ecbm_signaling_handler_dispatch(hci_con_handle_t handle, uint16 } } - if (security_status != L2CAP_ECBM_CONNECTION_RESULT_ALL_SUCCESS){ - l2cap_register_signaling_response(handle, L2CAP_CREDIT_BASED_CONNECTION_REQUEST, sig_id, - num_channels_and_signaling_cid, security_status); - return 1; + // check if authentication is possible + bool send_pending = false; + if (security_status != L2CAP_ECBM_CONNECTION_RESULT_ALL_SUCCESS) { + if (gap_get_bondable_mode() != 0) { + // if possible, send pending and continue + send_pending = true; + } else { + // otherwise, send refused and abort + l2cap_register_signaling_response(handle, L2CAP_CREDIT_BASED_CONNECTION_REQUEST, sig_id, + num_channels_and_signaling_cid, L2CAP_ECBM_CONNECTION_RESULT_ALL_PENDING_AUTHENTICATION); + return 1; + } } // report the last result code != 0 @@ -4008,7 +4016,7 @@ static int l2cap_ecbm_signaling_handler_dispatch(hci_con_handle_t handle, uint16 // if security is pending, send intermediate response, otherwise, ask user if (send_pending){ l2cap_register_signaling_response(handle, L2CAP_CREDIT_BASED_CONNECTION_REQUEST, sig_id, - num_channels_and_signaling_cid, security_status); + num_channels_and_signaling_cid, L2CAP_ECBM_CONNECTION_RESULT_ALL_PENDING_AUTHENTICATION); } else { l2cap_ecbm_handle_security_level_incoming_sufficient(a_channel); }