File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -354,6 +354,10 @@ void updateSerial()
354354 {
355355 commandLength = availableRXCommandBytes ();
356356
357+ // Don't overflow the command buffer, save space for the zero termination
358+ if (commandLength >= sizeof (commandBuffer))
359+ commandLength = sizeof (commandBuffer) - 1 ;
360+
357361 for (x = 0 ; x < commandLength ; x++)
358362 {
359363 commandBuffer[x] = commandRXBuffer[commandRXTail++];
@@ -454,7 +458,23 @@ void processSerialInput()
454458 {
455459 // Move this character into the command buffer
456460 commandBuffer[commandLength++] = incoming;
457- commandLength %= sizeof (commandBuffer);
461+
462+ // Don't allow the command to overflow the command buffer
463+ // Process the long command instead
464+ // Save room for the zero termination
465+ if (commandLength >= (sizeof (commandBuffer) - 1 ))
466+ {
467+ printerEndpoint = PRINT_TO_SERIAL;
468+ systemPrintln ();
469+ if (settings.debugSerial )
470+ {
471+ systemPrint (" processSerialInput moved " );
472+ systemPrint (commandLength);
473+ systemPrintln (" from serialReceiveBuffer into commandBuffer" );
474+ }
475+ checkCommand (); // Process command buffer
476+ break ;
477+ }
458478 }
459479 }
460480 }
You can’t perform that action at this time.
0 commit comments