From 1460e1a68221fca854b7b1e278cab76e763c00e6 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 4 May 2026 12:19:04 +0200 Subject: [PATCH] check if data fits writeBuffer before copy --- src/utility/ATT.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utility/ATT.cpp b/src/utility/ATT.cpp index ba717543..8a46e37c 100644 --- a/src/utility/ATT.cpp +++ b/src/utility/ATT.cpp @@ -1314,6 +1314,10 @@ void ATTClass::writeReqOrCmd(uint16_t connectionHandle, uint16_t mtu, uint8_t op writeBuffer[writeBufferSize] = valueLength; writeBufferSize += sizeof(valueLength); + if (writeBufferSize + valueLength > sizeof(writeBuffer)) { + sendError(connectionHandle, op, handle, ATT_ECODE_INSUFF_RESOURCES); + return; + } memcpy(&writeBuffer[writeBufferSize], value, valueLength); writeBufferSize += valueLength; }else{