From 0a9efbf85d0ed295446db3da310e4662e39e2d15 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Sun, 6 Jun 2021 12:13:48 -0500 Subject: [PATCH] fix(ble): Ignore out of range profiles Don't allow selecting a BLE profile that is out of range to avoid reading/writing past the end of the profiles array. --- app/src/ble.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/ble.c b/app/src/ble.c index b15a079e..a9f2afe9 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -250,6 +251,10 @@ static int ble_save_profile() { } int zmk_ble_prof_select(uint8_t index) { + if (index >= PROFILE_COUNT) { + return -ERANGE; + } + LOG_DBG("profile %d", index); if (active_profile == index) { return 0;