Bluetooth: HCI: Use skb_pull_data to parse Number of Complete Packets event
This uses skb_pull_data to check the Number of Complete Packets events received have the minimum required length. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
e3f3a1aea8
commit
aadc3d2f42
@ -2139,7 +2139,7 @@ struct hci_comp_pkts_info {
|
|||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct hci_ev_num_comp_pkts {
|
struct hci_ev_num_comp_pkts {
|
||||||
__u8 num_hndl;
|
__u8 num;
|
||||||
struct hci_comp_pkts_info handles[];
|
struct hci_comp_pkts_info handles[];
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
|
@ -4465,23 +4465,25 @@ static void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
|
|||||||
|
|
||||||
static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
|
static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct hci_ev_num_comp_pkts *ev = (void *) skb->data;
|
struct hci_ev_num_comp_pkts *ev;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
ev = hci_ev_skb_pull(hdev, skb, HCI_EV_NUM_COMP_PKTS, sizeof(*ev));
|
||||||
|
if (!ev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!hci_ev_skb_pull(hdev, skb, HCI_EV_NUM_COMP_PKTS,
|
||||||
|
flex_array_size(ev, handles, ev->num)))
|
||||||
|
return;
|
||||||
|
|
||||||
if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) {
|
if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) {
|
||||||
bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode);
|
bt_dev_err(hdev, "wrong event for mode %d", hdev->flow_ctl_mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skb->len < sizeof(*ev) ||
|
BT_DBG("%s num %d", hdev->name, ev->num);
|
||||||
skb->len < struct_size(ev, handles, ev->num_hndl)) {
|
|
||||||
BT_DBG("%s bad parameters", hdev->name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
|
for (i = 0; i < ev->num; i++) {
|
||||||
|
|
||||||
for (i = 0; i < ev->num_hndl; i++) {
|
|
||||||
struct hci_comp_pkts_info *info = &ev->handles[i];
|
struct hci_comp_pkts_info *info = &ev->handles[i];
|
||||||
struct hci_conn *conn;
|
struct hci_conn *conn;
|
||||||
__u16 handle, count;
|
__u16 handle, count;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user