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 @@ -32,6 +32,10 @@ void Commander::run(){
3232 received_chars[0 ] = 0 ;
3333 rec_cnt=0 ;
3434 }
35+ if (rec_cnt>=MAX_COMMAND_LENGTH) { // prevent buffer overrun if message is too long
36+ received_chars[0 ] = 0 ;
37+ rec_cnt=0 ;
38+ }
3539 }
3640}
3741
Original file line number Diff line number Diff line change 77#include " ../common/lowpass_filter.h"
88#include " commands.h"
99
10+
11+ #define MAX_COMMAND_LENGTH 20
12+
13+
1014// Commander verbose display to the user type
1115enum VerboseMode{
1216 nothing = 0 , // display nothing - good for monitoring
@@ -174,7 +178,7 @@ class Commander
174178 int call_count = 0 ;// !< number callbacks that are subscribed
175179
176180 // helping variable for serial communication reading
177- char received_chars[20 ] = {0 }; // !< so far received user message - waiting for newline
181+ char received_chars[MAX_COMMAND_LENGTH ] = {0 }; // !< so far received user message - waiting for newline
178182 int rec_cnt = 0 ; // !< number of characters receives
179183
180184 // serial printing functions
You can’t perform that action at this time.
0 commit comments