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.
This commit is contained in:
Joel Spadin 2021-06-06 12:13:48 -05:00 committed by Pete Johanson
parent efcc49f23d
commit 0a9efbf85d

View file

@ -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;