Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino M0 board crashes when setting BLE handle from data buffer #370

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading