Fix bell-append off-by-one write past payload buffer (#11099)

The send_bell append writes bytes[size] and bytes[size+1] while the guard only checked size < DATA_PAYLOAD_LEN, overrunning the 233-byte payload array by one when size == DATA_PAYLOAD_LEN - 1. Guard on size + 1.
This commit is contained in:
Thomas Göttgens
2026-07-20 18:38:50 -05:00
committed by GitHub
co-authored by GitHub
parent 6f522aad17
commit b8fb42c065
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ void DetectionSensorModule::sendDetectionMessage()
p->want_ack = false;
p->decoded.payload.size = strlen(message);
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);
if (moduleConfig.detection_sensor.send_bell && p->decoded.payload.size < meshtastic_Constants_DATA_PAYLOAD_LEN) {
if (moduleConfig.detection_sensor.send_bell && p->decoded.payload.size + 1 < meshtastic_Constants_DATA_PAYLOAD_LEN) {
p->decoded.payload.bytes[p->decoded.payload.size] = 7; // Bell character
p->decoded.payload.bytes[p->decoded.payload.size + 1] = '\0'; // Bell character
p->decoded.payload.size++;