File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ void Commander::run(Stream& serial, char eol){
47
47
received_chars[0 ] = 0 ;
48
48
rec_cnt=0 ;
49
49
}
50
+ if (rec_cnt>=MAX_COMMAND_LENGTH) { // prevent buffer overrun if message is too long
51
+ received_chars[0 ] = 0 ;
52
+ rec_cnt=0 ;
53
+ }
50
54
}
51
55
52
56
com_port = tmp; // reset the instance to the internal value
Original file line number Diff line number Diff line change 7
7
#include " ../common/lowpass_filter.h"
8
8
#include " commands.h"
9
9
10
+
11
+ #define MAX_COMMAND_LENGTH 20
12
+
13
+
10
14
// Commander verbose display to the user type
11
15
enum VerboseMode{
12
16
nothing = 0 , // display nothing - good for monitoring
@@ -178,7 +182,7 @@ class Commander
178
182
int call_count = 0 ;// !< number callbacks that are subscribed
179
183
180
184
// helping variable for serial communication reading
181
- char received_chars[20 ] = {0 }; // !< so far received user message - waiting for newline
185
+ char received_chars[MAX_COMMAND_LENGTH ] = {0 }; // !< so far received user message - waiting for newline
182
186
int rec_cnt = 0 ; // !< number of characters receives
183
187
184
188
// serial printing functions
You can’t perform that action at this time.
0 commit comments