OSDN Git Service

Fix insufficient buffer size allocation in hci_inject
authorMudumba Ananth <ananthm@broadcom.com>
Thu, 4 Jun 2015 13:00:48 +0000 (06:00 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Mon, 15 Jun 2015 22:28:46 +0000 (15:28 -0700)
A bug in the hci_inject when requesting a buffer to carry the
injected HCI packet. The allocated size should include the BT_HDR
header size.

Change-Id: Ic1fd41264249103140ce50dff843a99a6bd7dbd8

hci/src/hci_inject.c

index 169295b..a17a3d3 100644 (file)
@@ -167,7 +167,7 @@ static void read_ready(UNUSED_ATTR socket_t *socket, void *context) {
     // TODO(sharvil): once we have an HCI parser, we can eliminate
     //   the 2-byte size field since it will be contained in the packet.
 
-    BT_HDR *buf = (BT_HDR *)buffer_allocator->alloc(packet_len);
+    BT_HDR *buf = (BT_HDR *)buffer_allocator->alloc(BT_HDR_SIZE + packet_len);
     if (buf) {
       buf->event = hci_packet_to_event(packet_type);
       buf->offset = 0;