OSDN Git Service

Fixes two bluetooth bugs causing remote overreads (2/2)
authorakirilov <akirilov@google.com>
Fri, 27 Apr 2018 22:05:14 +0000 (15:05 -0700)
committerAtanas Kirilov <akirilov@google.com>
Fri, 1 Jun 2018 18:49:10 +0000 (18:49 +0000)
Bug: 74075873
Test: manual

Change-Id: I28a78084a1ab451b407ee6e7a5495c1e43ed757b
Merged-In: I76058b11c90dc40b78f26fb64b74d609f3473f5d

stack/sdp/sdp_discovery.c

index 18cd319..fef98d9 100644 (file)
@@ -358,7 +358,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;
@@ -389,6 +389,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;
+        }
 #if (SDP_DEBUG_RAW == TRUE)
         SDP_TRACE_WARNING("list_len :%d cpy_len:%d raw_size:%d raw_used:%d",
             list_len, cpy_len, p_ccb->p_db->raw_size, p_ccb->p_db->raw_used);