[LORA] Fix buffer overflow when converting binary packets to hex (#2402)

TheengsUtils::_rawToHex() formats each byte with "%02X\r", so the last
sprintf writes two bytes past the 2 * size hex digits (the '\r' and the
terminating null). LORAtoX() sized its buffer 2 * packetSize + 1, one
byte short, overflowing the stack for every binary LoRa packet.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pwshandClaude Opus 5.5 authored and GitHub committed 2026-10-12 06:51:09 -05:00
1 parent 3ec01a72fd
commit 3986d9d1f7
1 file changed
+1 -1
+1 -1
View File
@@ -459,7 +459,7 @@ void LORAtoX() {
return;
}
// We have non-ascii data: create hex string of the data
char hex[packetSize * 2 + 1];
char hex[packetSize * 2 + 2]; // _rawToHex writes "%02X\r" per byte: needs 2 * size + 2
TheengsUtils::_rawToHex(packet, hex, packetSize);
// Terminate with a null character
hex[packetSize * 2] = 0;