Skip to content

Commit af96ed2

Browse files
Flavio Ceolinjgl-meta
authored andcommitted
bt: host: Fix possible buffer overflow
Check in bt_conn_le_start_encryption if the given ltk fits in bt_conn.ltk before copying it. Signed-off-by: Flavio Ceolin <[email protected]> (cherry picked from commit fbd56fd)
1 parent 1e2850d commit af96ed2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,6 +2159,10 @@ int bt_conn_le_start_encryption(struct bt_conn *conn, uint8_t rand[8],
21592159
struct bt_hci_cp_le_start_encryption *cp;
21602160
struct net_buf *buf;
21612161

2162+
if (len > sizeof(cp->ltk)) {
2163+
return -EINVAL;
2164+
}
2165+
21622166
buf = bt_hci_cmd_create(BT_HCI_OP_LE_START_ENCRYPTION, sizeof(*cp));
21632167
if (!buf) {
21642168
return -ENOBUFS;

0 commit comments

Comments
 (0)