mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(ble/bluedroid): reject invalid ATT error code 0x00 on client
Map received error reason 0x00 to GATT_UNKNOWN_ERROR so the client
does not report GATT_SUCCESS with zero-length data on malformed errors.
(cherry picked from commit 1b6f9380f4)
Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
This commit is contained in:
@@ -571,6 +571,11 @@ void gatt_process_error_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
|
|||||||
STREAM_TO_UINT16(handle, p);
|
STREAM_TO_UINT16(handle, p);
|
||||||
STREAM_TO_UINT8(reason, p);
|
STREAM_TO_UINT8(reason, p);
|
||||||
|
|
||||||
|
/* 0x00 is not a valid ATT error code; treat as unknown error. */
|
||||||
|
if (reason == GATT_SUCCESS) {
|
||||||
|
reason = GATT_UNKNOWN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if (p_clcb->operation == GATTC_OPTYPE_DISCOVERY) {
|
if (p_clcb->operation == GATTC_OPTYPE_DISCOVERY) {
|
||||||
gatt_proc_disc_error_rsp(p_tcb, p_clcb, opcode, handle, reason);
|
gatt_proc_disc_error_rsp(p_tcb, p_clcb, opcode, handle, reason);
|
||||||
} else {
|
} else {
|
||||||
@@ -579,9 +584,6 @@ void gatt_process_error_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
|
|||||||
(opcode == GATT_REQ_PREPARE_WRITE) &&
|
(opcode == GATT_REQ_PREPARE_WRITE) &&
|
||||||
(p_attr) &&
|
(p_attr) &&
|
||||||
(handle == p_attr->handle) ) {
|
(handle == p_attr->handle) ) {
|
||||||
if (reason == GATT_SUCCESS){
|
|
||||||
reason = GATT_ERROR;
|
|
||||||
}
|
|
||||||
p_clcb->status = reason;
|
p_clcb->status = reason;
|
||||||
gatt_send_queue_write_cancel(p_tcb, p_clcb, GATT_PREP_WRITE_CANCEL);
|
gatt_send_queue_write_cancel(p_tcb, p_clcb, GATT_PREP_WRITE_CANCEL);
|
||||||
} else if ((p_clcb->operation == GATTC_OPTYPE_READ) &&
|
} else if ((p_clcb->operation == GATTC_OPTYPE_READ) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user