Skip to content

Commit a28b703

Browse files
seeersfallberg
authored andcommitted
Avoid data array overflow (#1142)
Occurs through packet collisions. Sometimes a wrong length is received.
1 parent f934d7c commit a28b703

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

hal/transport/RS485/MyTransportRS485.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ bool _serialProcess()
155155
_recPhase = 1;
156156
_recPos = 0;
157157

158+
//Avoid _data[] overflow
159+
if (_recLen >= MY_RS485_MAX_MESSAGE_LENGTH) {
160+
_serialReset();
161+
break;
162+
}
163+
158164
//Check if we should process this message
159165
//We reject the message if we are the sender
160166
//We reject if we are not the receiver and message is not a broadcast

0 commit comments

Comments
 (0)