mirror of https://github.com/ARMmbed/mbed-os.git
fix using an invalid cccd index
parent
8b623156e5
commit
366a5018b5
|
@ -222,8 +222,8 @@ private:
|
||||||
void add_generic_attribute_service();
|
void add_generic_attribute_service();
|
||||||
void* alloc_block(size_t block_size);
|
void* alloc_block(size_t block_size);
|
||||||
GattCharacteristic* get_auth_char(uint16_t value_handle);
|
GattCharacteristic* get_auth_char(uint16_t value_handle);
|
||||||
bool get_cccd_id(GattAttribute::Handle_t cccd_handle, uint8_t& idx) const;
|
bool get_cccd_index_by_cccd_handle(GattAttribute::Handle_t cccd_handle, uint8_t& idx) const;
|
||||||
bool has_cccd(GattAttribute::Handle_t char_handle) const;
|
bool get_cccd_index_by_value_handle(GattAttribute::Handle_t char_handle, uint8_t& idx) const;
|
||||||
bool is_update_authorized(Gap::Handle_t connection, GattAttribute::Handle_t value_handle);
|
bool is_update_authorized(Gap::Handle_t connection, GattAttribute::Handle_t value_handle);
|
||||||
|
|
||||||
struct alloc_block_t {
|
struct alloc_block_t {
|
||||||
|
|
|
@ -560,7 +560,7 @@ ble_error_t GattServer::read(
|
||||||
) {
|
) {
|
||||||
// Check to see if this is a CCCD
|
// Check to see if this is a CCCD
|
||||||
uint8_t cccd_index;
|
uint8_t cccd_index;
|
||||||
if (get_cccd_id(att_handle, cccd_index)) {
|
if (get_cccd_index_by_cccd_handle(att_handle, cccd_index)) {
|
||||||
if (connection == DM_CONN_ID_NONE) {
|
if (connection == DM_CONN_ID_NONE) {
|
||||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
@ -588,7 +588,7 @@ ble_error_t GattServer::write(
|
||||||
// Check to see if this is a CCCD, if it is the case update the value for all
|
// Check to see if this is a CCCD, if it is the case update the value for all
|
||||||
// connections
|
// connections
|
||||||
uint8_t cccd_index;
|
uint8_t cccd_index;
|
||||||
if (get_cccd_id(att_handle, cccd_index)) {
|
if (get_cccd_index_by_cccd_handle(att_handle, cccd_index)) {
|
||||||
if (len != sizeof(uint16_t)) {
|
if (len != sizeof(uint16_t)) {
|
||||||
return BLE_ERROR_INVALID_PARAM;
|
return BLE_ERROR_INVALID_PARAM;
|
||||||
}
|
}
|
||||||
|
@ -615,7 +615,7 @@ ble_error_t GattServer::write(
|
||||||
}
|
}
|
||||||
|
|
||||||
// return if the update does not have to be propagated to peers
|
// return if the update does not have to be propagated to peers
|
||||||
if (local_only || !has_cccd(att_handle)) {
|
if (local_only || !get_cccd_index_by_value_handle(att_handle, cccd_index)) {
|
||||||
return BLE_ERROR_NONE;
|
return BLE_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,7 +660,7 @@ ble_error_t GattServer::write(
|
||||||
) {
|
) {
|
||||||
// Check to see if this is a CCCD
|
// Check to see if this is a CCCD
|
||||||
uint8_t cccd_index;
|
uint8_t cccd_index;
|
||||||
if (get_cccd_id(att_handle, cccd_index)) {
|
if (get_cccd_index_by_cccd_handle(att_handle, cccd_index)) {
|
||||||
if ((connection == DM_CONN_ID_NONE) || (len != 2)) { // CCCDs are always 16 bits
|
if ((connection == DM_CONN_ID_NONE) || (len != 2)) { // CCCDs are always 16 bits
|
||||||
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
return BLE_ERROR_PARAM_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
@ -677,7 +677,7 @@ ble_error_t GattServer::write(
|
||||||
}
|
}
|
||||||
|
|
||||||
// return if the update does not have to be propagated to peers
|
// return if the update does not have to be propagated to peers
|
||||||
if (local_only || !has_cccd(att_handle)) {
|
if (local_only || !get_cccd_index_by_value_handle(att_handle, cccd_index)) {
|
||||||
return BLE_ERROR_NONE;
|
return BLE_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1211,7 +1211,7 @@ GattCharacteristic* GattServer::get_auth_char(uint16_t value_handle)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GattServer::get_cccd_id(GattAttribute::Handle_t cccd_handle, uint8_t& idx) const
|
bool GattServer::get_cccd_index_by_cccd_handle(GattAttribute::Handle_t cccd_handle, uint8_t& idx) const
|
||||||
{
|
{
|
||||||
for (idx = 0; idx < cccd_cnt; idx++) {
|
for (idx = 0; idx < cccd_cnt; idx++) {
|
||||||
if (cccd_handle == cccds[idx].handle) {
|
if (cccd_handle == cccds[idx].handle) {
|
||||||
|
@ -1221,10 +1221,10 @@ bool GattServer::get_cccd_id(GattAttribute::Handle_t cccd_handle, uint8_t& idx)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GattServer::has_cccd(GattAttribute::Handle_t char_handle) const
|
bool GattServer::get_cccd_index_by_value_handle(GattAttribute::Handle_t char_handle, uint8_t& idx) const
|
||||||
{
|
{
|
||||||
for (uint8_t cccd_index = 0; cccd_index < cccd_cnt; ++cccd_index) {
|
for (idx = 0; idx < cccd_cnt; ++idx) {
|
||||||
if (char_handle == cccd_handles[cccd_index]) {
|
if (char_handle == cccd_handles[idx]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue