From 8f3a392f4d5c8b75a3f7e1acc6ffe0acc2d407a2 Mon Sep 17 00:00:00 2001 From: treston Date: Tue, 13 Oct 2026 10:54:52 -0500 Subject: [PATCH] fix(mavlink): fit a full-size signed frame in the send buffer (#29164) send_bytes() rejected a chunk when it filled the buffer exactly. The buffer is MAVLINK_MAX_PACKET_LEN (280) bytes, which is the size of a signed frame with a 255-byte payload, so the last chunk of such a frame (its signature) was dropped while the rest was sent with the signed flag set. With signing enabled every LOGGING_DATA frame of the MAVLink log streaming was unparsable and the receiver also lost the following frame. (cherry picked from commit 0a33696cb94ec40a7760a14a242feb23f208f5b8) Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Ramon Roche --- src/modules/mavlink/mavlink_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/mavlink/mavlink_main.cpp b/src/modules/mavlink/mavlink_main.cpp index f5ba0ae54af..0056781bd04 100644 --- a/src/modules/mavlink/mavlink_main.cpp +++ b/src/modules/mavlink/mavlink_main.cpp @@ -1000,7 +1000,8 @@ void Mavlink::send_finish() void Mavlink::send_bytes(const uint8_t *buf, unsigned packet_len) { if (!_tx_buffer_low) { - if (_buf_fill + packet_len < sizeof(_buf)) { + // _buf holds exactly one maximum-length frame (280 bytes for a signed frame with a 255-byte payload) + if (_buf_fill + packet_len <= sizeof(_buf)) { memcpy(&_buf[_buf_fill], buf, packet_len); _buf_fill += packet_len;