diff options
author | Joel Spadin <joelspadin@gmail.com> | 2021-06-06 12:13:48 -0500 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2021-06-08 20:33:43 -0400 |
commit | 0a9efbf85d0ed295446db3da310e4662e39e2d15 (patch) | |
tree | a75ae2e37a24f6997547d9b35a6b9f078026c031 /app/src | |
parent | efcc49f23dba0fa896c5cc0603e3fc9c664af166 (diff) |
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.
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/ble.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/app/src/ble.c b/app/src/ble.c index b15a079..a9f2afe 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -7,6 +7,7 @@ #include <device.h> #include <init.h> +#include <errno.h> #include <math.h> #include <stdlib.h> #include <stdio.h> @@ -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; |