OSDN Git Service

RESTRICT AUTOMERGE: Fixes two bluetooth causing remote overreads (2/2)
authorakirilov <akirilov@google.com>
Fri, 27 Apr 2018 22:12:59 +0000 (15:12 -0700)
committerRyan Longair <rlongair@google.com>
Tue, 12 Jun 2018 18:14:33 +0000 (11:14 -0700)
Bug: 74075873
Test: manual
Change-Id: I76058b11c90dc40b78f26fb64b74d609f3473f5d
(cherry picked from commit 23918433c1f4970ae04c09a9fe096bf87cd83d76)

stack/sdp/sdp_discovery.c

index f831fdc..b01d834 100644 (file)
@@ -353,7 +353,7 @@ static void process_service_search_rsp(tCONN_CB *p_ccb, UINT8 *p_reply,
 #if (SDP_RAW_DATA_INCLUDED == TRUE)
 static void sdp_copy_raw_data (tCONN_CB *p_ccb, BOOLEAN offset)
 {
-    unsigned int    cpy_len;
+    unsigned int    cpy_len, rem_len;
     UINT32          list_len;
     UINT8           *p;
     UINT8           type;
@@ -384,6 +384,11 @@ static void sdp_copy_raw_data (tCONN_CB *p_ccb, BOOLEAN offset)
         {
             cpy_len = list_len;
         }
+        rem_len = SDP_MAX_LIST_BYTE_COUNT - (unsigned int)(p - &p_ccb->rsp_list[0]);
+        if (cpy_len > rem_len) {
+            SDP_TRACE_WARNING("rem_len :%d less than cpy_len:%d", rem_len, cpy_len);
+            cpy_len = rem_len;
+        }
         SDP_TRACE_WARNING(
           "%s: list_len:%d cpy_len:%d p:%p p_ccb:%p p_db:%p raw_size:%d "
           "raw_used:%d raw_data:%p",