From eef16ce34abb977d147d637c6751b69bf5b1161b Mon Sep 17 00:00:00 2001 From: fabik111 Date: Thu, 3 Oct 2024 14:52:10 +0200 Subject: [PATCH] fix crashes on M0 board when assigning the BLE handle from the received data buffer --- src/utility/ATT.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utility/ATT.cpp b/src/utility/ATT.cpp index b1796c90..9367cfbf 100644 --- a/src/utility/ATT.cpp +++ b/src/utility/ATT.cpp @@ -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()) { @@ -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) { pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy