nimble/ans: Fix out of bounds access

cat_id is used as index to access ble_svc_ans_new_alert_cnt and
ble_svc_ans_unr_alert_cnt and shall be validated before doing so.

X-Original-Commit: 5d8dbaf5e22c9f6cbf2370a03410a0cef0fca83a
This commit is contained in:
Szymon Janc
2017-08-18 14:12:36 +02:00
parent 947a8ab17d
commit 2b5468af44
+3 -1
View File
@@ -221,13 +221,15 @@ ble_svc_ans_access(uint16_t conn_handle, uint16_t attr_handle,
cmd_id = ble_svc_ans_alert_not_ctrl_pt[0];
cat_id = ble_svc_ans_alert_not_ctrl_pt[1];
/* Set cat_bit_mask to the appropriate bitmask based on cat_id */
if (cat_id < BLE_SVC_ANS_CAT_NUM) {
cat_bit_mask = (1 << cat_id);
} else if (cat_id == 0xff) {
cat_bit_mask = cat_id;
} else {
cat_bit_mask = 0;
/* invalid category ID */
return BLE_ATT_ERR_UNLIKELY;
}
switch (cmd_id) {