aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>2011-12-30 05:07:47 -0500
committerGustavo F. Padovan <padovan@profusion.mobi>2012-01-02 22:38:37 -0500
commitc5993de864d96b3656e9fca38c377b130105d97a (patch)
treee44d03d2348a89b6bebad1cca98a06006b1ccfaa /net
parent3542b854bc26e5f8e42e0eab4d7f7453b74a362d (diff)
Bluetooth: Correct packet len calculation
Remove unneeded skb_pull and correct packet length calculation removing magic number. Move BT_DBG after len check otherwise it could possibly access wrong memory. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_event.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 08c0b4295ecc..d37f5b2a3e3c 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2271,20 +2271,19 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
2271 struct hci_ev_num_comp_pkts *ev = (void *) skb->data; 2271 struct hci_ev_num_comp_pkts *ev = (void *) skb->data;
2272 int i; 2272 int i;
2273 2273
2274 skb_pull(skb, sizeof(*ev));
2275
2276 BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
2277
2278 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) { 2274 if (hdev->flow_ctl_mode != HCI_FLOW_CTL_MODE_PACKET_BASED) {
2279 BT_ERR("Wrong event for mode %d", hdev->flow_ctl_mode); 2275 BT_ERR("Wrong event for mode %d", hdev->flow_ctl_mode);
2280 return; 2276 return;
2281 } 2277 }
2282 2278
2283 if (skb->len < ev->num_hndl * 4) { 2279 if (skb->len < sizeof(*ev) || skb->len < sizeof(*ev) +
2280 ev->num_hndl * sizeof(struct hci_comp_pkts_info)) {
2284 BT_DBG("%s bad parameters", hdev->name); 2281 BT_DBG("%s bad parameters", hdev->name);
2285 return; 2282 return;
2286 } 2283 }
2287 2284
2285 BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
2286
2288 for (i = 0; i < ev->num_hndl; i++) { 2287 for (i = 0; i < ev->num_hndl; i++) {
2289 struct hci_comp_pkts_info *info = &ev->handles[i]; 2288 struct hci_comp_pkts_info *info = &ev->handles[i];
2290 struct hci_conn *conn; 2289 struct hci_conn *conn;