mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
fix(bt/bluedroid): fixed OOB read in SDP server continuation length
This commit is contained in:
@@ -179,7 +179,6 @@ static void process_service_search (tCONN_CB *p_ccb, UINT16 trans_num,
|
||||
tSDP_RECORD *p_rec = NULL;
|
||||
BT_HDR *p_buf;
|
||||
BOOLEAN is_cont = FALSE;
|
||||
UNUSED(p_req_end);
|
||||
|
||||
p_req = sdpu_extract_uid_seq (p_req, param_len, &uid_seq);
|
||||
|
||||
@@ -214,6 +213,10 @@ static void process_service_search (tCONN_CB *p_ccb, UINT16 trans_num,
|
||||
}
|
||||
|
||||
/* Check if this is a continuation request */
|
||||
if (p_req + 1 > p_req_end) {
|
||||
sdpu_build_n_send_error (p_ccb, trans_num, SDP_INVALID_CONT_STATE, SDP_TEXT_BAD_CONT_LEN);
|
||||
return;
|
||||
}
|
||||
if (*p_req) {
|
||||
if (*p_req++ != SDP_CONTINUATION_LEN || (p_req >= p_req_end)) {
|
||||
sdpu_build_n_send_error (p_ccb, trans_num, SDP_INVALID_CONT_STATE,
|
||||
@@ -351,6 +354,10 @@ static void process_service_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
|
||||
}
|
||||
|
||||
/* Check if this is a continuation request */
|
||||
if (p_req + 1 > p_req_end) {
|
||||
sdpu_build_n_send_error (p_ccb, trans_num, SDP_INVALID_CONT_STATE, SDP_TEXT_BAD_CONT_LEN);
|
||||
return;
|
||||
}
|
||||
if (*p_req) {
|
||||
/* Free and reallocate buffer */
|
||||
if (p_ccb->rsp_list) {
|
||||
@@ -565,7 +572,7 @@ static void process_service_search_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
|
||||
/* Extract the UUID sequence to search for */
|
||||
p_req = sdpu_extract_uid_seq (p_req, param_len, &uid_seq);
|
||||
|
||||
if ((!p_req) || (!uid_seq.num_uids)) {
|
||||
if ((!p_req) || (!uid_seq.num_uids) || (p_req + 2 > p_req_end)) {
|
||||
sdpu_build_n_send_error (p_ccb, trans_num, SDP_INVALID_REQ_SYNTAX, SDP_TEXT_BAD_UUID_LIST);
|
||||
return;
|
||||
}
|
||||
@@ -586,7 +593,16 @@ static void process_service_search_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
|
||||
|
||||
memcpy(&attr_seq_sav, &attr_seq, sizeof(tSDP_ATTR_SEQ)) ;
|
||||
|
||||
if (max_list_len < 4) {
|
||||
sdpu_build_n_send_error (p_ccb, trans_num, SDP_ILLEGAL_PARAMETER, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if this is a continuation request */
|
||||
if (p_req + 1 > p_req_end) {
|
||||
sdpu_build_n_send_error(p_ccb, trans_num, SDP_INVALID_CONT_STATE, SDP_TEXT_BAD_CONT_LEN);
|
||||
return;
|
||||
}
|
||||
if (*p_req) {
|
||||
/* Free and reallocate buffer */
|
||||
if (p_ccb->rsp_list) {
|
||||
@@ -600,7 +616,7 @@ static void process_service_search_attr_req (tCONN_CB *p_ccb, UINT16 trans_num,
|
||||
return;
|
||||
}
|
||||
|
||||
if (*p_req++ != SDP_CONTINUATION_LEN) {
|
||||
if ((*p_req++ != SDP_CONTINUATION_LEN) || (p_req + 2 > p_req_end)) {
|
||||
sdpu_build_n_send_error (p_ccb, trans_num, SDP_INVALID_CONT_STATE, SDP_TEXT_BAD_CONT_LEN);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user