Skip to content

Commit

Permalink
fix crashes on M0 board when assigning the BLE handle from the receiv…
Browse files Browse the repository at this point in the history
…ed data buffer
  • Loading branch information
fabik111 committed Oct 3, 2024
1 parent 29bef40 commit 2e66711
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utility/ATT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,8 +993,8 @@ void ATTClass::readOrReadBlobReq(uint16_t connectionHandle, uint16_t mtu, uint8_
}
/// if auth error, hold the response in a buffer.
bool holdResponse = false;

uint16_t handle = *(uint16_t*)data;
uint16_t handle;
memcpy(&handle, data, sizeof(handle));
uint16_t offset = (opcode == ATT_OP_READ_REQ) ? 0 : *(uint16_t*)&data[sizeof(handle)];

if ((uint16_t)(handle - 1) > GATT.attributeCount()) {
Expand Down Expand Up @@ -1248,7 +1248,8 @@ void ATTClass::writeReqOrCmd(uint16_t connectionHandle, uint16_t mtu, uint8_t op
return;
}

uint16_t handle = *(uint16_t*)data;
uint16_t handle;
memcpy(&handle, data, sizeof(handle));

if ((uint16_t)(handle - 1) > GATT.attributeCount()) {
if (withResponse) {
Expand Down

0 comments on commit 2e66711

Please sign in to comment.