OSDN Git Service

GAP: Correct the continuous pkt length in l2cap
authorVenkata Jagadeesh Garaga <vgaraga@codeaurora.org>
Thu, 18 Apr 2019 11:43:49 +0000 (17:13 +0530)
committerJack He <siyuanh@google.com>
Fri, 15 Nov 2019 22:00:10 +0000 (22:00 +0000)
L2cap continuous pkt length wrongly calculated in
reassembly logic when remote sends more data
than expected.

Wrong pkt length leading to memory corruption

Hence the Correct the continuous pkt length in
l2cap reassembly logic.

Bug: 135239489
Bug: 143894715
CRs-Fixed: 2434229
Test: make and internal testing
Change-Id: I758d9e31465b99e436b9b1841320000f08186c97
Merged-In: I758d9e31465b99e436b9b1841320000f08186c97
(cherry picked from commit 337bd4579453bd6bf98ff519de3ac1019cd30d28)

hci/src/packet_fragmenter.cc

index 7ac4850..3a1175e 100644 (file)
@@ -214,7 +214,8 @@ static void reassemble_and_dispatch(UNUSED_ATTR BT_HDR* packet) {
                  "%s got packet which would exceed expected length of %d. "
                  "Truncating.",
                  __func__, partial_packet->len);
-        packet->len = partial_packet->len - partial_packet->offset;
+        packet->len =
+            (partial_packet->len - partial_packet->offset) + packet->offset;
         projected_offset = partial_packet->len;
       }